computinglife
computinglife

Reputation: 4391

Can Flask be run with threaded=true, fronted by an afficient web server / proxy

My intention is to not use WSGI and simply let Python run as a flask server, serving multiple requests simultaneously without using the WSGI interface (aka gunicorn and such). I want to use a single process to make it simpler to use SQLite which is restricted to a single process ateast for writes and avoid re-initializing the workers every time they start.

There seems to have been other requests answered along these lines in the past (which advise that the included web server in flask is not production ready) and i want to check if this has improved or is doable with a proxy in front.

This is the deployment I'm targeting -

  1. Nginx which allows a fixed no of upstream requests at a time (so that flask web server is not overwhelmed)
  2. Flask running in a threaded manner (same container as Nginx)
  3. python 3.12.+
  4. The required throughput is very low and the app is not exposed to the internet. (5 requests per second max)

Is this doable ? Or is gunicorn still the way to go?

Upvotes: 0

Views: 19

Answers (0)

Related Questions