navapbc / template-application-flask

Apache License 2.0
7 stars 3 forks source link

Run flask using production wsgi/http server #174

Closed lorenyu closed 1 year ago

lorenyu commented 1 year ago

Flask's built in web server is meant for development, not production (see https://flask.palletsprojects.com/en/2.3.x/deploying/) so we need to install an additional library to make it work in production. A few past projects used gunicorn so let's go with that

There are some notes on configuration and design in this 🔒 slack thread. tldr; we may want to consider len(os.sched_getaffinity(0)) * 2 for number of workers, hardcode number of threads (e.g. 4), and have some sort of override/flag for the command in docker-compose to bypass gunicorn when running locally.