Byoungchan Lee
Byoungchan Lee

Reputation: 1492

Can Flask run on Gunicorn alone?

I'm currently developing HTTP Rest API server using Flask and Gunicorn. For various reason, it is not possible to put a reverse proxy server in front of Gunicorn. I don't have any static media, and all url are being served by @app.route pattern in Flask Framework. Can Flask run on Gunicorn alone?

Upvotes: 2

Views: 1333

Answers (1)

Bastian
Bastian

Reputation: 10433

It could, but it is a very bad idea. Gunicorn is not working well without a proxy that is doing request and response buffering for slow clients.

Without buffering the gunicorn worker has to wait until the client has send the whole request and then has to wait until the client has read the whole response.

This can be a serious problem if there are clients on a slow network for example.

http://docs.gunicorn.org/en/latest/deploy.html?highlight=buffering

see also: http://blog.etianen.com/blog/2014/01/19/gunicorn-heroku-django/

Because Gunicorn has a relatively small (2x CPU cores) pool of workers, if can only handle a small number of concurrent requests. If all the worker processes become tied up waiting for network traffic, the entire server will become unresponsive. To the outside world, your web application will cease to exist.

Upvotes: 6

Related Questions