gunicorn 部署问题

2017-04-25 11:24:55 +08:00
 cloudyplain

最近做 python server 的选型, gunicorn+meinheld/gevent 都不错,但在 nginx 下性能、错误率掉得有点厉害,远不如 nginx+uWSGI+gevent 稳定,请教下如何部署?

gunicorn -b :18003 -k egg:meinheld#gunicorn_worker  -w 9 mybottle:app 

#or

gunicorn -b :18003 -k gevent_pywsgi  -w 9    mybottle:app

nginx.conf

    server {
        listen 8003;
        location / {
            proxy_pass http://127.0.0.1:18003;
        }
    }

谢谢!

2920 次点击
所在节点    Python
9 条回复
ryd994
2017-04-25 21:53:53 +08:00
Nginx 后面挂普通 gunicorn 呢?
gunicorn 最初的设计就是这样
junnplus
2017-04-25 22:20:19 +08:00
没有说明机子配置就直接 -w 9 合适么
junnplus
2017-04-25 22:41:49 +08:00
另外 meinheld 在请求高的时候错误率确实会飙高,可以看看这个测评 https://blog.appdynamics.com/engineering/a-performance-analysis-of-python-wsgi-servers-part-2/
cloudyplain
2017-04-25 23:38:23 +08:00
@junnplus 4 核,因为和问题无关就没有说明,另外 它这个评测 meinheld 是不开 keep-alive 的,我自己测试时没有这么多错误。
cloudyplain
2017-04-25 23:40:09 +08:00
@ryd994 默认工作模式是阻塞调用,性能不成吧。
ryd994
2017-04-26 00:29:41 +08:00
@cloudyplain 默认设计是 Nginx 在前面 buffer
gunicorn 只需要以最快速度和 Nginx 交换数据并处理请求就行,所以阻塞不会影响性能,这是 gunicorn 官方的说法
cloudyplain
2017-04-26 09:13:23 +08:00
@ryd994 并不是,一旦 app 中有 block io 这个进程就阻塞了。
tanywei
2017-04-26 10:26:49 +08:00
回复 mark 一下
PythonAnswer
2017-04-26 11:01:04 +08:00
digitalocean 有相关部署文章

nginx+gunicorn+gevent 是最稳定高效的组合

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/357198

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX