Recall & Review
beginner
What is Gunicorn in the context of Flask applications?
Gunicorn is a production-ready web server that runs Flask applications efficiently by managing multiple worker processes to handle requests.
Click to reveal answer
beginner
Why should you use Gunicorn instead of Flask's built-in server in production?
Flask's built-in server is for development only; it is single-threaded and not optimized for handling many users. Gunicorn can handle multiple requests concurrently and is more stable for production use.
Click to reveal answer
beginner
How do you start a Flask app with Gunicorn on the command line?
Use the command:
gunicorn app:app where the first app is the Python file name (without .py) and the second app is the Flask application instance.Click to reveal answer
intermediate
What does the
-w option do when running Gunicorn?The
-w option sets the number of worker processes Gunicorn will use to handle requests. More workers can handle more users at the same time.Click to reveal answer
beginner
Name one benefit of using multiple Gunicorn workers for a Flask app.
Multiple workers allow the app to handle many requests at once, improving speed and reliability, especially under heavy traffic.
Click to reveal answer
What is the main reason to use Gunicorn with Flask in production?
✗ Incorrect
Gunicorn manages multiple worker processes to handle many requests efficiently, which Flask's built-in server cannot do well.
Which command starts a Flask app named 'app.py' with Gunicorn?
✗ Incorrect
The correct Gunicorn command uses the format 'gunicorn filename:app_instance', so 'gunicorn app:app' runs the app in 'app.py'.
What does the '-w 4' option do when running Gunicorn?
✗ Incorrect
The '-w' option sets the number of worker processes; '-w 4' means Gunicorn will use 4 workers.
Is Flask's built-in server suitable for production use?
✗ Incorrect
Flask's built-in server is not designed for production; it lacks performance and security features needed for real users.
Which of these is a benefit of using Gunicorn workers?
✗ Incorrect
Multiple workers let Gunicorn handle many requests simultaneously, improving app responsiveness.
Explain why Gunicorn is preferred over Flask's built-in server for production.
Think about how many users your app can serve at once.
You got /4 concepts.
Describe how to run a Flask app with Gunicorn and how to adjust its performance.
Focus on the command line and worker settings.
You got /4 concepts.