measure with keep-alive on; cold connects inflate p99.
SQLAlchemy AsyncSession inside BackgroundTasks? — follow-up #2
Hit this after a routine bump.
Symptom: SQLAlchemy AsyncSession inside BackgroundTasks? — follow-up #2
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?
10 replies
paste engine kwargs and max_connections. worker×pool is the usual culprit.
dropping pool_size per worker fixed it for us on the same box size.
check proxy_read_timeout before blaming uvicorn resets.
paste engine kwargs and max_connections. worker×pool is the usual culprit.
dropping pool_size per worker fixed it for us on the same box size.
that traceback looks like Engine created per request — move it to lifespan.
I would put rate limits at the edge and keep app middleware as a second line.
measure with keep-alive on; cold connects inflate p99.
we fixed the same class of bug by moving Engine creation into lifespan.