C10K 要不要求响应时间和 RQS - V2EX
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
mengzhuo

C10K 要不要求响应时间和 RQS

  •  
  •   mengzhuo Jul 23, 2014 4333 views
    This topic created in 4296 days ago, the information mentioned may be changed or developed.
    我的应用是bottle 做app, gevent做wsgiserver
    简单的echo程序


    用ab测试自己的app,发现
    Requests per second: 2017.96 [#/sec] (mean)
    测试时Python进程已经100%了

    可这应该根本不算能承受C10K吧....,有什么地方我错了?


    ab -c 10000 -n 10000 -r http://localhost:8998/echo
    This is ApacheBench, Version 2.3 <$Revision: 1528965 $>
    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 1000 requests
    Completed 2000 requests
    Completed 3000 requests
    Completed 4000 requests
    Completed 5000 requests
    Completed 6000 requests
    Completed 7000 requests
    Completed 8000 requests
    Completed 9000 requests
    Completed 10000 requests
    Finished 10000 requests


    Server Software:
    Server Hostname: localhost
    Server Port: 8998

    Document Path: /echo
    Document Length: 16 bytes

    Concurrency Level: 10000
    Time taken for tests: 4.956 seconds
    Complete requests: 10000
    Failed requests: 0
    Total transferred: 1430000 bytes
    HTML transferred: 160000 bytes
    Requests per second: 2017.96 [#/sec] (mean)
    Time per request: 4955.05 [ms] (mean)
    Time per request: 0.496 [ms] (mean, across all concurrent requests)
    Transfer rate: 281.80 [Kbytes/sec] received

    Connection Times (ms)
    min mean[+/-sd] median max
    Connect: 0 832 1042.9 253 3009
    Processing: 6 192 284.3 67 1688
    Waiting: 2 192 284.3 67 1688
    Total: 47 1024 1118.6 789 4682

    18 replies    2014-07-23 17:46:18 +08:00
    ipconfiger
        1
    ipconfiger  
       Jul 23, 2014
    ab -c 10000 -n 10000 -r http://localhost:8998/echo 你在开玩笑的吧
    est
        2
    est  
       Jul 23, 2014
    槽点太多。不知道从哪里吐。
    mengzhuo
        3
    mengzhuo  
    OP
       Jul 23, 2014
    @ipconfiger

    C10K = concurrently 10*1000 = 10000 我这数学应该没错吧……
    mengzhuo
        4
    mengzhuo  
    OP
       Jul 23, 2014
    @est

    欢迎来吐……我真是菜鸟……
    fanta
        5
    fanta  
       Jul 23, 2014   1
    c10k指的应该是接入socket的数量, 不包含其它的处理,每个socket都会占用内存的,所以机器的内存太小也不行.
    ipconfiger
        6
    ipconfiger  
       Jul 23, 2014   1
    keep住1W个链接,并不代表每秒能处理1w的请求啊,1W的连接数和1W的QPS是两码事哦
    mengzhuo
        7
    mengzhuo  
    OP
       Jul 23, 2014
    @ipconfiger
    @fanta

    原来是这样……
    那怎么测试C10K?
    只需要
    ```
    [socket.socket().connect(('localhost', 8998)) for x in xrange(10000)]
    ```
    ipconfiger
        8
    ipconfiger  
       Jul 23, 2014
    多找点机器来当客户端,每个客户端1K个连接嘛,然后频繁的发ping pong
    mengzhuo
        9
    mengzhuo  
    OP
       Jul 23, 2014
    @ipconfiger

    我单机链接的……

    tcp 0 0 127.0.0.1:8998 127.0.0.1:42207 ESTABLISHED
    tcp 0 0 127.0.0.1:34349 127.0.0.1:8998 ESTABLISHED

    ......

    $ netstat -nt | grep 8998 | wc -l
    20004

    这样算不算C10K了……只要不发数据包,gevent太淡定了,直接hold住了
    julyclyde
        10
    julyclyde  
       Jul 23, 2014   1
    @mengzhuo C10K在当代本来就不是难事啊,以至于单独去测试“保持10K个连接”已经是没有意义的事了。还是讨论处理请求的能力吧
    ipconfiger
        11
    ipconfiger  
       Jul 23, 2014   1
    @mengzhuo 现在的机器性能来说这都是很easy的,别人都在show单机100W连接了,连接起完了20多G内存就不见了
    mengzhuo
        12
    mengzhuo  
    OP
       Jul 23, 2014
    @julyclyde
    @ipconfiger

    原来是遗留的问题
    我还是折腾RQS吧

    我是双核PC
    同样输出一样的HTML模板,单核下,bottle 和 nginx 都只能1300左右RQS,
    协程果然牛B

    不过nginx升到4 个workers就能1W4 RQS....乖乖起4个线程跑应用好了
    mengskysama
        13
    mengskysama  
       Jul 23, 2014   1
    CK10 保持住1W链接,ping pong。不能用http来测试。

    其实没必要这么测。在另外多启动几台机器启动1000线程不断进行HTTP REQ,这样测试出来更有意义。
    mengzhuo
        14
    mengzhuo  
    OP
       Jul 23, 2014
    @mengskysama

    按你说的方法测试了一下,

    其他机子竟然可以有这种响应速度了……

    Requests per second: 2487.28 [#/sec] (mean)
    Time per request: 40.205 [ms] (mean)
    Time per request: 0.402 [ms] (mean, across all concurrent requests)
    Transfer rate: 347.34 [Kbytes/sec] received
    mengzhuo
        15
    mengzhuo  
    OP
       Jul 23, 2014
    最差的机子上也是

    Requests per second: 1012.04 [#/sec] (mean)
    Time per request: 98.810 [ms] (mean)
    Time per request: 0.988 [ms] (mean, across all concurrent requests)
    Transfer rate: 5709.52 [Kbytes/sec] received

    照这个处理速度和能力……只是访问主页的话能顶住8千万日PV?
    wecoders
        16
    wecoders  
       Jul 23, 2014
    @mengzhuo 正常情况下,web不会有10k的并发量,200-500差不多了吧?
    mengskysama
        17
    mengskysama  
       Jul 23, 2014
    @mengzhuo 妥妥的,试试flask我印象中结果更快。。。。虽然没啥意义就是了。好像还支持多线程来着
    mengskysama
        18
    mengskysama  
       Jul 23, 2014
    有一个测试。。虽然也是没意义的。
    http://www.cnbeta.com/articles/178726.htm

    谁好用我用谁,谁文档全用谁,谁更新用谁(最后能打的就那2,3个
    About     Help     Advertise     Blog     API     FAQ     Solana     1296 Onlie   Highest 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 45ms UTC 17:28 PVG 01:28 LAX 10:28 JFK 13:28
    Do have faith in what you're doing.
    ubao msn snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86