Why Your FastAPI Is Not FastA deep dive into hidden bottlenecks
Five anti-patterns, real measurements, runnable demos.
Five anti-patterns, real measurements, runnable demos.
FastAPI gives you the tools, but it does not protect you from yourself. Each card below is one anti-pattern from the talk, with the headline measurement from the captured Postgres runs. Each pattern has a bad and a good endpoint on the same running service.
async def freezes the whole event loop. 3.05 s → 1.04 s for three concurrent requests.
17.48 ms → 1.73 ms mean per request.
MissingGreenlet or quietly issues one query per row. 6 → 2 queries for five orders.
~1.9× slower, ~1.8× more function calls.
2.1% → 0% failures at 47.8 → 179.3 req/s.
Pick the time you have. The same material is organised differently for each.