discussion 2026-10-31 1301 views 14 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?

7 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.

@eng_1012_82
2026-11-23 00:58 UTC · 4 votes

measure p99 with keep-alive; cold connects lie.

@helen_go
2026-11-23 22:01 UTC · 0 votes

yes, rate-limit echo. it is a free amplifier otherwise.

@eng_1007_87
2026-11-23 22:01 UTC · 2 votes

middleware that opens db sessions will bite you under load.

Reply

Login or register to reply.