V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
Distributions
Ubuntu
Fedora
CentOS
中文资源站
网易开源镜像站
gouera
V2EX  ›  Linux

关于ab压力测试的问题

  •  
  •   gouera · 2013-11-25 15:58:31 +08:00 · 4254 次点击
    这是一个创建于 3777 天前的主题,其中的信息可能已经有所发展或是发生改变。
    [root@bogon ~]# ab -n 1000 -c 1000 http://www.cncar.com/index.php
    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 www.cncar.com (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
    apr_poll: The timeout specified has expired (70007)
    Total of 858 requests completed


    -n是发送1000个请求吧,
    -c发送1000个并发这个就不是很懂了 ,是说一次请求访问1000次吗?最近在看HTTP权威指南,希望能更加理解吧。

    上面的这个结果是表示这个网站最多支持858个人同时访问index.php页面吗?
    7 条回复    1970-01-01 08:00:00 +08:00
    xdays
        1
    xdays  
       2013-11-25 16:40:08 +08:00
    并发,同时发起的请求数。

    这个结果表示在1000并发时成功率为85.8%
    Johnny
        2
    Johnny  
       2013-11-25 16:56:09 +08:00
    1、光压index.php没意义,看哪里业务处理较复杂,压预估瓶颈位置,有精力就全部都压一压,包括一切json请求。

    2、如果全站能扛得住1000并发已经相当不错了, 当然前提是要有个满意的响应时间。
    3、你的测试 本来要请求1000次,到858次之后已经timeout了
    insight
        3
    insight  
       2013-11-25 16:59:20 +08:00
    同时建立-c条TCP连接,然后这-c条连接一直发,在响应时间大于等于-t的超时时间或者所有的-n条请求数已经被发送完毕时,停止发送。

    -n requests Number of requests to perform
    -c concurrency Number of multiple requests to make
    -t timelimit Seconds to max. wait for responses

    ab.c的源代码:
    http://svn.apache.org/repos/asf/httpd/httpd/trunk/support/ab.c

    重点是static void test(void)函数的实现。
    siw
        4
    siw  
       2013-11-25 17:15:32 +08:00
    用 weighttp 替代 ab
    gouera
        5
    gouera  
    OP
       2013-11-26 08:51:33 +08:00
    @Johnny 就主页是最大的了,其他都是一些比较小的页面。 这个结果就是说这个网站的index.php页面最多只能支持同时858个人访问对吗?
    如果我ab -n 1000 -c 1 是不是1000个人依次访问这个网站呢。。
    gouera
        6
    gouera  
    OP
       2013-11-26 08:51:59 +08:00
    @insight 太高端,看的不怎么明白.
    gouera
        7
    gouera  
    OP
       2013-11-26 09:02:45 +08:00
    @Johnny 刚才看了下相关的信息,是不是访问一个页面,先发送一个请求, 然后再看浏览器能支持几个并发。
    就好像chrome 就是 一个请求6个并发?
    如果要测某页面能不能支持1000个人同时访问,那我是不是要 发1000个请求 . 6000个并发了啊?
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2884 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 32ms · UTC 13:06 · PVG 21:06 · LAX 06:06 · JFK 09:06
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.