Python web servers handle traffic with a fixed number of workers and threads, so a wrong count shows up as timeouts at peak. These recipes size Gunicorn, keep blocking calls off FastAPI's event loop and stop Django from exhausting Postgres. Start with Fix Gunicorn WORKER TIMEOUT and Size Workers.
- Django CONN_MAX_AGE, Connection Pooling and PgBouncer
Match CONN_MAX_AGE or Django's pool to your worker count, and add Django PgBouncer settings when pods multiply, so peak traffic stops exhausting Postgres.
- Fix Gunicorn WORKER TIMEOUT and Size Workers
Size Gunicorn workers and threads from the pod's CPU and memory, and order your timeouts, so peak traffic stops killing workers mid-request.
- Fix FastAPI Blocking Calls in Async Routes
Keep blocking calls off the event loop with async clients, def routes or run_in_threadpool, so one slow call stops stalling every request in the process.