solved 2026-11-09 1140 views 10 votes

uvicorn --reload in compose is eating CPU

@piotr
Backend Engineer

Hit this in staging after bumping workers.

Error / symptom: uvicorn --reload in compose is eating CPU

Traceback (most recent call last):
  File "app/main.py", line 42, in endpoint
    await db.execute(stmt)
TimeoutError: connection pool exhausted

Env: Python 3.12, FastAPI 0.115, uvicorn workers=4, Postgres 16.
What am I missing in pool settings?

5 replies

@mei
2026-11-09 05:33 UTC · 9 votes

try pool_timeout=30 and lower pool_size to 5 per worker first.

@elias
2026-11-09 09:39 UTC · 5 votes

orjson helps CPU a bit; it will not save a saturated DB.

@tara
2026-11-09 17:54 UTC · 1 votes

nginx buffering? if upstream resets, look at proxy_read_timeout before blaming uvicorn.

@leo_cache
2026-11-09 18:38 UTC · 7 votes

orjson helps CPU a bit; it will not save a saturated DB.

@kai_sre
2026-11-09 19:37 UTC · 11 votes

nginx buffering? if upstream resets, look at proxy_read_timeout before blaming uvicorn.