uwsgi服务器性能测试,gunicorn、uwsgi性能测试

本文通过基准测试比较了uWSGI和Gunicorn在部署Python应用时的性能。在Intel Core i5-3230M CPU和7.4GiB内存的Ubuntu 14.04环境中,使用Apache Bench工具进行压力测试。结果显示,uWSGI在并发请求响应速度上优于Gunicorn,平均响应时间更短,但Gunicorn的总数据传输量更大。测试结论表明,uWSGI在高并发场景下可能更具优势。
摘要由CSDN通过智能技术生成

目的,测试在不同的部署方式下的性能。

硬件环境

Intel Core i5-3230M CPU @ 2.60GHz × 4

内存: 7.4 GiB

操作系统: Ubuntu 14.04 64 位

测试代码(hello.py)

from bottle import Bottle, run

app = Bottle()

@app.route('/hello')

def hello():

return "Hello World!"

if __name__ == "__main__":

run(app, host='localhost', port=8000)

uwsgi

uwsgi_python --http-socket=:8000 --workers=2 --wsgi-file hello.py --callable app 2>/dev/null

结果:

ab -c 100 -n 50000 "http://localhost:8000/hello"

This is ApacheBench, Version 2.3

Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/

Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking localhost (be patient)

Completed 5000 requests

Completed 10000 requests

Completed 15000 requests

Completed 20000 requests

Completed 25000 requests

Completed 30000 requests

Completed 35000 requests

Completed 40000 requests

Completed 45000 requests

Completed 50000 requests

Finished 50000 requests

Server Software:

Server Hostname:        localhost

Server Port:            8000

Document Path:          /hello

Document Length:        12 bytes

Concurrency Level:      100

Time taken for tests:   3.288 seconds

Complete requests:      50000

Failed requests:        0

Total transferred:      4550000 bytes

HTML transferred:       600000 bytes

Requests per second:    15206.71 [#/sec] (mean)

Time per request:       6.576 [ms] (mean)

Time per request:       0.066 [ms] (mean, across all concurrent requests)

Transfer rate:          1351.38 [Kbytes/sec] received

Connection Times (ms)

min  mean[+/-sd] median   max

Connect:        0    2   1.3      2       6

Processing:     1    5   1.3      4      14

Waiting:        1    4   1.7      4      12

Total:          4    7   0.8      6      19

WARNING: The median and mean for the total time are not within a normal deviation

These results are probably not that reliable.

Percentage of the requests served within a certain time (ms)

50%      6

66%      7

75%      7

80%      7

90%      7

95%      7

98%      8

99%     11

100%     19 (longest request)

gunicorn

gunicorn -w 2 hello:app

结果:

ab -c 100 -n 50000 "http://localhost:8000/hello"

This is ApacheBench, Version 2.3

Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/

Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking localhost (be patient)

Completed 5000 requests

Completed 10000 requests

Completed 15000 requests

Completed 20000 requests

Completed 25000 requests

Completed 30000 requests

Completed 35000 requests

Completed 40000 requests

Completed 45000 requests

Completed 50000 requests

Finished 50000 requests

Server Software:        gunicorn/19.3.0

Server Hostname:        localhost

Server Port:            8000

Document Path:          /hello

Document Length:        12 bytes

Concurrency Level:      100

Time taken for tests:   8.821 seconds

Complete requests:      50000

Failed requests:        0

Total transferred:      8600000 bytes

HTML transferred:       600000 bytes

Requests per second:    5668.37 [#/sec] (mean)

Time per request:       17.642 [ms] (mean)

Time per request:       0.176 [ms] (mean, across all concurrent requests)

Transfer rate:          952.11 [Kbytes/sec] received

Connection Times (ms)

min  mean[+/-sd] median   max

Connect:        0    0   0.3      0       7

Processing:     3   18   2.0     17      34

Waiting:        3   17   2.0     17      34

Total:         10   18   2.0     17      36

Percentage of the requests served within a certain time (ms)

50%     17

66%     17

75%     18

80%     18

90%     19

95%     23

98%     23

99%     24

100%     36 (longest request)

总结

方案并发最大响应时间(ms)

uwsgi1520619

gunicorn566836

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值