【问题标题】:Python App Servers (Bjoern vs Gunicorn)Python 应用服务器(Bjoern 与 Gunicorn)
【发布时间】:2017-01-07 12:03:42
【问题描述】:

我正在对 python WSGI 应用服务器进行基准测试。

我运行 bjoern 如下:

bjoern.run(wsgi_app, host, port)

还有 Gunicorn:

gunicorn -w 2 --bind 0.0.0.0:5000 gun_server:wsgi_app --log-level=DEBUG --timeout 90

但是,我发现 Bjoern 处理的请求数量是 Gunicorn 的一半。我进行基准测试的节点有 2 个 vCPU。

根据迄今为止发表的许多文章(例如) https://dzone.com/articles/a-performance-analysis-of-python-wsgi-servers-part 与 Gunicorn 相比,Bjoern 在每秒处理许多请求方面应该要好得多。

按照此操作使 Bjoren 能够在多个内核上运行 https://github.com/jonashaag/bjoern/blob/master/tests/fork.py

但 Bjoern 仍处理比 Gunicorn 处理的请求的一半多一点

Bjoren 似乎在使用多个内核:

vin@TEST:~/api/src$ ps -U $USER -o pid,psr,comm | grep python
27880   1 python
27921   1 python
27922   1 python
vin@TEST:~/api/src$ ps -U $USER -o pid,psr,comm | grep python
27880   1 python
27921   1 python
27922   0 python
vin@TEST:~/api/src$ ps -U $USER -o pid,psr,comm | grep python
27880   1 python
27921   1 python
27922   1 python
vin@TEST:~/api/src$ ps -U $USER -o pid,psr,comm | grep python
27880   1 python
27921   1 python
27922   1 python
vin@TEST:~/api/src$ ps -U $USER -o pid,psr,comm | grep python
27880   1 python
27921   0 python
27922   0 python

任何想法如何调试这个?

[更新] 我在不支持 SO_REUSEPORT 的 3.2.0-115-virtual 上。这会显着影响请求/秒吗?

【问题讨论】:

    标签: python performance webserver gunicorn bjoern


    【解决方案1】:

    Bjoern 使用一个核心,gunicorn 使用两个核心。 因此,gunicorn 正在处理(约 2 倍)更多请求是有道理的。

    【讨论】:

    • 是的,谢谢,注意到了。我已经使用 os.fork() 更新了代码。基准测试目前正在运行。
    • 关注这个:github.com/jonashaag/bjoern/blob/master/tests/fork.py 但是,Bjoern 处理的请求量仍然是 Gunicorn 的一半。我应该如何调试这个?有两个进程python(27880)─┬─python(27921)└─python(27922)
    • 我注意到的另一件事是我在不支持 SO_REUSEPORT 的 Linux 3.2 上。这会显着影响请求/秒吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-12-27
    • 2021-08-13
    • 2011-07-25
    • 2019-02-16
    • 1970-01-01
    相关资源
    最近更新 更多