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

Can Flask run on Gunicorn alone?

我目前正在使用 Flask 和 Gunicorn 开发 HTTP Rest API 服务器。由于各种原因,不可能在 Gunicorn 前面放置一个反向代理服务器。我没有任何静态媒体,所有 url 都由 Flask 框架中的 @app.route 模式提供服务。 Flask 运行 可以单独在 Gunicorn 上使用吗?

可以,但这是一个非常糟糕的主意。如果没有为慢速客户端执行请求和响应缓冲的代理,Gunicorn 将无法正常工作。

如果没有缓冲,gunicorn worker 必须等到客户端发送了整个请求,然后必须等到客户端读取了整个响应。

例如,如果客户端在慢速网络上,这可能是一个严重的问题。

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

另请参阅: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.