简体   繁体   English

Flask可以单独在Gunicorn上运行吗?

[英]Can Flask run on Gunicorn alone?

I'm currently developing HTTP Rest API server using Flask and Gunicorn. 我目前正在使用Flask和Gunicorn开发HTTP Rest API服务器。 For various reason, it is not possible to put a reverse proxy server in front of Gunicorn. 由于各种原因,不可能将反向代理服务器放在Gunicorn的前面。 I don't have any static media, and all url are being served by @app.route pattern in Flask Framework. 我没有任何静态媒体,并且所有网址都由Flask Framework中的@app.route模式提供。 Can Flask run on Gunicorn alone? Flask可以单独在Gunicorn上运行吗?

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. 没有代理为慢速客户端执行请求和响应缓冲的代理,Gunicorn不能很好地工作。

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 http://docs.gunicorn.org/en/latest/deploy.html?highlight=buffering

see also: http://blog.etianen.com/blog/2014/01/19/gunicorn-heroku-django/ 另请参阅: 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. 由于Gunicorn的工作人员池相对较小(2个CPU内核),因此只能处理少量的并发请求。 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. 对于外部世界,您的Web应用程序将不复存在。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM