/ writing

Walkthrough: profiling a slow API endpoint

Recorded session — the video embed goes here.

This is a recorded session, not a write-up. I take one real endpoint that should respond in 40ms and takes 900ms, and trace it end to end with nothing fancier than a profiler, a database query log, and some patience. No framework magic, no secret tools — the point is to watch the reasoning, not the clicks.

What the session covers

We start by reproducing the latency deterministically, because a bug you can't summon on demand will waste the whole session. Then we read the flame graph — and I mean read it, top-down, asking what each wide frame is actually holding. The first suspect (a missing index) turns out to be innocent; the real cost is hidden in serialisation of a response nobody reads.

Half of profiling is learning what is NOT slow, and believing the measurement anyway.

We fix it in two steps — first the cheap 10x, then the structural change that keeps it from creeping back — and end by writing the regression test that would have caught this before it shipped. The recording runs about twenty minutes.