Interview Prep/Python for DevOps/Testing, CI/CD, packaging & services

A Flask app runs with `app.run()` in production and falls over under load. What do you change?

BeginnerScenarioTesting, CI/CD, packaging & services
Answer

Situation read → The development server is single-process and not built for production.

What I'd do →

  1. Run under gunicorn: gunicorn -w 4 -k gthread --threads 4 -b 0.0.0.0:8000 --timeout 30 app:app.
  2. Size workers to CPU (roughly 2 x cores + 1 as a start) and measure.
  3. Put it behind a reverse proxy or load balancer; add health endpoints.
  4. Set --graceful-timeout and handle SIGTERM for clean deploys.

Why → A real WSGI server handles concurrency, worker restarts and timeouts.

Interview tip → Mention the dev server warning itself says not to use it in production.

All Python for DevOps questions Roadmap: Python for automation

More on Testing, CI/CD, packaging & services