discussion 2026-10-31 1202 views 9 votes

asyncpg statement cache size for 50 endpoints

@vera_rs
Rust Engineer

Hit this after a routine bump.

Symptom: asyncpg statement cache size for 50 endpoints

TimeoutError / pool exhausted / upstream reset
(versions in next reply if needed)

Env: Python 3.12, FastAPI recent, uvicorn workers≥2.
What should I check first?

4 replies

@rine
2026-10-31 08:50 UTC · 3 votes

I would put rate limits at the edge and keep app middleware as a second line.

@piotr
2026-10-31 23:58 UTC · 8 votes

minimal repro with ASGITransport would help more than screenshots.

@piotr
2026-11-01 10:12 UTC · 8 votes

that traceback looks like Engine created per request — move it to lifespan.

@mira_py
2026-11-01 20:02 UTC · 8 votes

measure with keep-alive on; cold connects inflate p99.

Reply

Login or register to reply.