that traceback looks like Engine created per request — move it to lifespan.
uvicorn --workers vs gunicorn+uvicorn workers for FastAPI — follow-up #1
Hit this after a routine bump.
Symptom: uvicorn --workers vs gunicorn+uvicorn workers for FastAPI — follow-up #1
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?
11 replies
I would put rate limits at the edge and keep app middleware as a second line.
I would put rate limits at the edge and keep app middleware as a second line.
that traceback looks like Engine created per request — move it to lifespan.
dropping pool_size per worker fixed it for us on the same box size.
marking solved after we pinned the dependency and re-smoked /docs.
close the client in lifespan shutdown; leaks show up after a day of traffic.
dropping pool_size per worker fixed it for us on the same box size.
orjson helped cpu a few percent; db still the ceiling.
if upstream resets, look at proxy_read_timeout next.
check your workers first; each one duplicates logging handlers.