Bird
0
0

You want to deploy a Flask app with Gunicorn on a server with 4 CPU cores. Which Gunicorn configuration is best to maximize performance without overloading the server?

hard📝 Application Q15 of 15
Flask - Performance Optimization
You want to deploy a Flask app with Gunicorn on a server with 4 CPU cores. Which Gunicorn configuration is best to maximize performance without overloading the server?
ARun Gunicorn with 8 workers and bind to 0.0.0.0:80
BRun Gunicorn with 1 worker and bind to 0.0.0.0:5000
CRun Gunicorn with 2 workers and bind to 0.0.0.0:8080
DRun Gunicorn with 4 workers and bind to 127.0.0.1:8000 behind a reverse proxy
Step-by-Step Solution
Solution:
  1. Step 1: Match workers to CPU cores

    Best practice is to run Gunicorn with number of workers equal to CPU cores (4 here) for optimal concurrency.
  2. Step 2: Bind to localhost and use reverse proxy

    Binding to 127.0.0.1:8000 and placing a reverse proxy (like Nginx) in front is a common production setup for security and performance.
  3. Final Answer:

    Run Gunicorn with 4 workers and bind to 127.0.0.1:8000 behind a reverse proxy -> Option D
  4. Quick Check:

    Workers = CPU cores, bind localhost + proxy = C [OK]
Quick Trick: Match workers to CPU cores; use localhost bind with reverse proxy [OK]
Common Mistakes:
MISTAKES
  • Using too many workers causing overload
  • Binding directly to port 80 without proxy
  • Using too few workers limiting performance

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Flask Quizzes