When I test my new Flask application with the built in web server, everything is "single threaded" and blocking. The server can not serve one request without finishing another. It can only process one request at a time.
When deploying a web service, this is obviously not desirable. How do you deploy Flask applications so that things can move in parallel?
Are there different things to consider regarding thread safety and concurrency inside the code (protect objects with locks and so on) or are all the offerings equivalent?
I use uWSGI with the gevent loop. That is the ticket. In fact, this is how I use py-redis which is blocking to not be blocking.
Also, I use uWSGI to write requests after the response while still accepting more requests.
There are a number of good options. I think the two most popular are probably:
Running it behind Apache with mod_wsgi or behind Nginx with uWsgi
Both of these have worked well for me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With