正在加载...

webpy-5 性能测试

webpy的性能真的是不敢恭维啊

代码如下:

#coding: utf-8    
import web

urls = (
    '/', 'Index'
)

class Index:

    def GET(self):
        return 'Hello, world !\n'



def start():
    app = web.application(urls, globals())
    app.run()


if __name__ == '__main__':
    start()

利用apache 的ab进行压力测试,10并发1000次请求:

ab -c 10 -n 1000 http://192.168.95.222:4321/

结果如下:

This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 192.168.95.222 (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Completed 600 requests
Completed 700 requests
Completed 800 requests
Completed 900 requests
Completed 1000 requests
Finished 1000 requests


Server Software:        CherryPy/3.1.2
Server Hostname:        192.168.95.222
Server Port:            4321

Document Path:          /
Document Length:        16 bytes

Concurrency Level:      10
Time taken for tests:   6.269 seconds
Complete requests:      1000
Failed requests:        0
Write errors:           0
Total transferred:      108000 bytes
HTML transferred:       16000 bytes
Requests per second:    159.51 [#/sec] (mean)
Time per request:       62.691 [ms] (mean)
Time per request:       6.269 [ms] (mean, across all concurrent requests)
Transfer rate:          16.82 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        1    1   0.3      1       5
Processing:    29   61  14.7     61     373
Waiting:       29   61  14.7     61     372
Total:         30   62  14.7     62     374

Percentage of the requests served within a certain time (ms)
  50%     62
  66%     64
  75%     65
  80%     66
  90%     68
  95%     70
  98%     71
  99%     73
 100%    374 (longest request)

平均每秒只能在160s,太低了。

再来看 100并发,2000请求

ab -c 100 -n 2000 http://192.168.95.222:4321/

结果

This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 192.168.95.222 (be patient)
Completed 200 requests
Completed 400 requests
Completed 600 requests
Completed 800 requests
Completed 1000 requests
Completed 1200 requests
Completed 1400 requests
Completed 1600 requests
Completed 1800 requests
Completed 2000 requests
Finished 2000 requests


Server Software:        CherryPy/3.1.2
Server Hostname:        192.168.95.222
Server Port:            4321

Document Path:          /
Document Length:        20 bytes

Concurrency Level:      100
Time taken for tests:   15.158 seconds
Complete requests:      2000
Failed requests:        0
Write errors:           0
Total transferred:      224000 bytes
HTML transferred:       40000 bytes
Requests per second:    131.94 [#/sec] (mean)
Time per request:       757.902 [ms] (mean)
Time per request:       7.579 [ms] (mean, across all concurrent requests)
Transfer rate:          14.43 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        1   37 203.5      1    1207
Processing:    58  707 915.3    640    6597
Waiting:       57  707 915.3    639    6596
Total:         61  744 1076.6    641    7802

Percentage of the requests served within a certain time (ms)
  50%    641
  66%    647
  75%    650
  80%    652
  90%    667
  95%   2641
  98%   7173
  99%   7674
 100%   7802 (longest request)

每秒:131个请求,响应时间是:757ms左右。无法忍受了。