01 / Performance
From 12 seconds to 20 milliseconds: when history is the bug
Cut a production OAuth2 configuration endpoint from up to 12 s to about 20 ms server-side, and brought distributed tracing to the platform.
01The problem
An OAuth2 configuration endpoint in the identity stack took up to 12 s in production. The federation connector calls it, so every slow call delayed client lookups. An earlier ticket had stalled without a root cause, and the cluster had no distributed tracing to show which query was slow.

02What I did
- Set up Jaeger in the cluster as a proof of concept with OpenTelemetry traces to see where time went.
- Followed the request through spans and SQL to the cause: every configuration update kept a full historical copy of the previous state, and the endpoint's queries read all historical rows, not just the active one.
- Mapped which components call the endpoint, then reproduced the slowdown on a DEV tenant by seeding history. About 600 client updates moved the median from 0.17 s to 6.8 s, matching production. One query scanned 2.5 million rows.
- Fix 1: switched the configuration writers to replace the active state instead of appending history.
- Fix 2: wrote a safe SQL cleanup that keeps active and future-dated states and removes obsolete history. One table went from 8,191 rows to 11.
- Added integration and performance scenarios, and wrote the analysis and verification page for the architects.
03Result
- Endpoint back to about 21 ms server-side (about 70 ms client median) in DEV verification, down from up to 12 s. That is roughly 99% faster.
- Tracing became a platform standard. After the proof of concept, I pitched it to the architects as an official tool. The platform now traces on Grafana, and I helped standardize span naming and attributes across services.