Selected work

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.

DeliveredJavaSQLOpenTelemetryJaegerKubernetes

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.

Bar chart of median endpoint latency on a DEV tenant: 0.17 s on fresh state, 6.8 s after about 600 client updates, and about 0.07 s after the fix.
Illustration, not a screenshot. Numbers and labels only, no internal systems.

02What I did

  1. Set up Jaeger in the cluster as a proof of concept with OpenTelemetry traces to see where time went.
  2. 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.
  3. 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.
  4. Fix 1: switched the configuration writers to replace the active state instead of appending history.
  5. 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.
  6. 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.