这是一个创建于 4122 天前的主题,其中的信息可能已经有所发展或是发生改变。
之前看到挺多同学推荐Gunicorn+Gevent来跑Flask的,就在机子上试了一下。一个简单的flask hello world程序,发现gevent似乎没有什么提升,是因为这种测试环境没有凸显异步的优势?
跟http://rfyiamcool.blog.51cto.com/1030776/1276364 这博文上说的结果有些不同。
用ab -c 100 -n 2000 参数测试
python直接启动gevent测试的负载
----------
Concurrency Level: 100
Time taken for tests: 1.651 seconds
Complete requests: 2000
Failed requests: 186
(Connect: 0, Receive: 0, Length: 186, Exceptions: 0)
Write errors: 0
Total transferred: 285814 bytes
HTML transferred: 25814 bytes
Requests per second: 1211.57 [#/sec] (mean)
Time per request: 82.537 [ms] (mean)
Time per request: 0.825 [ms] (mean, across all concurrent requests)
Transfer rate: 169.08 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 3 1.8 2 12
Processing: 19 79 27.2 63 127
Waiting: 18 78 27.5 62 127
Total: 24 81 26.5 66 131
Percentage of the requests served within a certain time (ms)
50% 66
66% 84
75% 119
80% 120
90% 122
95% 123
98% 124
99% 124
100% 131 (longest request)
---------
直接用gunicorn启动
----------------
Concurrency Level: 100
Time taken for tests: 1.665 seconds
Complete requests: 2000
Failed requests: 199
(Connect: 0, Receive: 0, Length: 199, Exceptions: 0)
Write errors: 0
Total transferred: 345801 bytes
HTML transferred: 25801 bytes
Requests per second: 1201.11 [#/sec] (mean)
Time per request: 83.256 [ms] (mean)
Time per request: 0.833 [ms] (mean, across all concurrent requests)
Transfer rate: 202.81 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 2 3.5 1 35
Processing: 7 80 28.5 66 140
Waiting: 7 80 28.4 66 140
Total: 15 82 28.0 67 142
Percentage of the requests served within a certain time (ms)
50% 67
66% 68
75% 85
80% 125
90% 132
95% 138
98% 140
99% 140
100% 142 (longest request)
--------------------
使用gunicorn -k gevent方式启动
---------------------
Concurrency Level: 100
Time taken for tests: 1.939 seconds
Complete requests: 2000
Failed requests: 203
(Connect: 0, Receive: 0, Length: 203, Exceptions: 0)
Write errors: 0
Total transferred: 345797 bytes
HTML transferred: 25797 bytes
Requests per second: 1031.36 [#/sec] (mean)
Time per request: 96.959 [ms] (mean)
Time per request: 0.970 [ms] (mean, across all concurrent requests)
Transfer rate: 174.14 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 2 4.3 1 43
Processing: 16 94 31.7 79 161
Waiting: 16 93 31.7 79 161
Total: 20 95 31.0 79 165
Percentage of the requests served within a certain time (ms)
50% 79
66% 113
75% 123
80% 123
90% 152
95% 154
98% 155
99% 156
100% 165 (longest request)
--------------------
4 条回复 • 1970-01-01 08:00:00 +08:00
|
|
1
ipconfiger 2013-08-22 16:15:44 +08:00 1
根本就没弄清除异步的实质企图依靠弄几个所谓神器来提高性能,基本上都是水中捞月望梅止渴而已。就跟弄了本黑魔法书来念咒语,却不知道召唤出来的是神是鬼。简直无法继续吐槽了
|
|
|
3
tinypig 2013-08-22 16:24:14 +08:00
@ ipconfiger 我的理解是Gevent可以在有网络延时、数据库响应的情景下提升服务器效率。但是看到有博客上有这样的测试,所以就来请教一下。
|