gevent 的异步 StreamServer

测试环境windows + python + gevent,有条件的朋友可以采用pypy测试。


code:

# -*- coding: UTF-8 -*-
from gevent.monkey import patch_all;patch_all()
from gevent.server import StreamServer


def main(socket,address):
    socket.recv(4096)
    socket.send("HTTP/1.1 200 OK\n\n<h1>Hello World!</h1>")



if __name__ == '__main__':
    Server = StreamServer(("192.168.1.190",80),main)
    Server.serve_forever()
    #Server.close()


测试工具(ab):

    

[root@test ~]# ab -c 200 -n 5000000  http://192.168.1.190/

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.1.190 (be patient)
Completed 500000 requests
Completed 1000000 requests
Completed 1500000 requests
Completed 2000000 requests
Completed 2500000 requests
Completed 3000000 requests
Completed 3500000 requests
Completed 4000000 requests
Completed 4500000 requests
Completed 5000000 requests
Finished 5000000 requests


Server Software:
Server Hostname:        192.168.1.190
Server Port:            80

Document Path:          /
Document Length:        21 bytes

Concurrency Level:      200
Time taken for tests:   493.025 seconds
Complete requests:      5000000
Failed requests:        0
Write errors:           0
Total transferred:      190000000 bytes
HTML transferred:       105000000 bytes
Requests per second:    10141.48 [#/sec] (mean)
Time per request:       19.721 [ms] (mean)
Time per request:       0.099 [ms] (mean, across all concurrent requests)
Transfer rate:          376.34 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    1   1.2      0      16
Processing:     3   19   3.8     18     136
Waiting:        1   19   3.8     18     136
Total:          3   20   3.8     19     138

Percentage of the requests served within a certain time (ms)
  50%     19
  66%     20
  75%     21
  80%     21
  90%     23
  95%     26
  98%     29
  99%     33
 100%    138(longest request)
 
[root@test ~]#



转载于:https://my.oschina.net/CandyMi/blog/670748

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值