discussion 2026-10-12 887 views 1 votes

Rate limit headers for sandbox clients

@cole
Senior Go Engineer

Hit this in staging after bumping workers.

Error / symptom: Rate limit headers for sandbox clients

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?

6 replies

@kai_sre
2026-10-12 02:42 UTC · 11 votes

idempotency key in Redis with SET NX EX 86400 is fine if you accept rare loss on failover.

@leda
2026-10-12 11:53 UTC · 7 votes

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

@helen_go
2026-10-13 00:31 UTC · 9 votes

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

@nox
2026-10-13 01:54 UTC · 3 votes

i saw the same when each worker opened its own pool of 20. math: 4*20 = 80 against a 50 max_connections box.

@mira_py
2026-10-13 07:28 UTC · 11 votes

I saw the same when each worker opened its own pool of 20. Math: 4*20 = 80 against a 50 max_connections box.

@sana
2026-10-13 08:00 UTC · 3 votes

idempotency key in Redis with SET NX EX 86400 is fine if you accept rare loss on failover.