discussion 2026-10-28 266 views 24 votes

Should we put Redis in front of /users?

@piotr
Backend Engineer

Hit this in staging after bumping workers.

Error / symptom: Should we put Redis in front of /users?

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

@tara
2026-10-28 13:21 UTC · 2 votes

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

@amira
2026-10-28 14:22 UTC · 7 votes

also check you are not creating an Engine inside the request.

@yuna
2026-10-29 00:12 UTC · 6 votes

also check you are not creating an Engine inside the request.

@mira_py
2026-10-29 10:49 UTC · 5 votes

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

@kai_sre
2026-10-29 14:34 UTC · 11 votes

paste your sqlalchemy engine kwargs. pool_size and max_overflow matter more than worker count here.