Which production server fits a low-traffic Flask app: Gunicorn with gthread, Uvicorn, or serverless?
0 reputation · 12 Jul 2021, 06:09 UTC
0 reputation · 12 Jul 2021, 06:09 UTC
I'm deploying a low-traffic Flask application (a few requests per minute at most) and want to minimize hosting costs without sacrificing correctness. The Flask documentation lists several deployment options but does not prescribe one, so the choice is left open.
The candidates I'm weighing are: Gunicorn with a single gthread worker, Uvicorn with async views on Flask 2.0+, and a serverless option such as AWS Lambda via Zappa. My endpoints are mostly I/O-bound (database calls and external APIs), and I rely on a few third-party extensions whose async compatibility I haven't audited. I also use before_request and teardown_request hooks, and I've read that these may behave differently under an ASGI lifespan model.
Constraints: I want to avoid the development server, keep memory footprint low, and would like to verify the decision with a benchmark rather than assumed behavior.
Specific questions:
A thoughtful contribution can make all the difference. Be the first to share one.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.