文章内容

2018/5/18 17:49:59,作 者: 黄兵

Gunicorn vs uwsgi

Gunicorn 和 uwsgi 都是实现了 wsgi 通信协议的server,都提供了 pre-fork 方式增加 server 并发处理能力。
现在对其做一个简单的性能测试对比,以便更好的在两者间做出选择。

测试机器性能:

  • CPU:Intel® Core™ i5-4200U CPU @ 1.60GHz × 4
  • RAM:8GB
  • OS:ubuntu 14.04 TLS 64bit

测试Server代码app.py:

1
2
3
4
5
# -*-coding: utf8-*-
def application(env, start_response):
start_response('200 OK', [('Content-Type', 'text/html')])
return [b'Hello World']

Gunicorn:

1
gunicorn -w 4 app:application -b 0.0.0.0:9000

uwsgi:

1
uwsgi --http :9000 --wsgi-file app.py --master --processes 4

测试用具使用 wrk

测试命令:

1
wrk -t12 -cnum -d30s http://127.0.0.1:9000/

启动12个线程,每次测试更新并发数num,测试持续30s。


测试结果如下:

  • 平均响应时间

    latency

  • 吞吐量

    req/sec

  • 错误数

    error


结论:

uwsgi在高并发下比gunicorn有更好的吞吐量和更少的错误数。

本文转载自:Gunicorn vs uwsgi

分享到:

发表评论

评论列表

user-ico

m on 回复 有用(1

你的博客主题颜色真好看,瞬间心情舒畅了。。。

游客kz)7 on 2018-09-13 08:49:05

博主回复:谢谢。