zoukankan      html  css  js  c++  java
  • ab压力测试

    原文链接:http://www.orlion.ga/698/

    ab是个什么就不说了搞lamp的都会知道。主要看一下结果都是什么意义。

    ab 的用法是:ab [options] [http://]hostname[:port]/path

    例如:ab -n 5000 -c 200 http://localhost/index.php

    上例表示总共访问http://localhost/index.php这个脚本5000次,200并发同时执行

     

    ab常用参数的介绍:

    -n :总共的请求执行数,缺省是1;

    -c: 并发数,缺省是1;

    -t:测试所进行的总时间,秒为单位,缺省50000s

    -p:POST时的数据文件

    -w: 以HTML表的格式输出结果

    执行测试用例:ab -n 1000 -c 100 -w http://localhost/index.php >>c:1.html

    上面的测试用例表示100并发的情况下,共测试访问index.php脚本1000次,并将测试结果保存到c:1.html文件中。

    测试一下:

        ab -n 1000 -c 100 http://localhost/index.php

        测试结果如下:

        

    结果解释一下:

        

    Server Software:        Apache/2.4.9    ##apache版本 
    Server Hostname:        localhost  ##请求的机子 
    Server Port:            80 ##请求端口

    Document Path:          /index.php 
    Document Length:        5456 bytes  ##页面长度

    Concurrency Level:      100  ##并发数 
    Time taken for tests:   4.591seconds  ##共使用了多少时间 
    Complete requests:      1000   ##请求数 
    Failed requests:        0   ##失败请求 
    Write errors:           0   
    Total transferred:      5645000bytes  ##总共传输字节数,包含http的头信息等 
    HTML transferred:       5456000bytes  ##html字节数,实际的页面传递字节数 
    Requests per second:    217.81 [#/sec] (mean)  ##每秒多少请求,这个是非常重要的参数数值,服务器的吞吐量 
    Time per request:       459.126[ms] (mean)  ##用户平均请求等待时间 
    Time per request:       4.591 [ms] (mean, across all concurrent requests)  ##并发的每个请求平均消耗时间 

    Transfer rate:          1200.69[Kbytes/sec] received  ##平均每秒网络上的流量,可以帮助排除是否存在网络流量过大导致响应时间延长的问题

    Connection Times(ms)    网络上消耗的时间的分解

    Percentage of the requests served within a certain time (ms) 
      50%     434  ## 50%的请求在434ms内返回 
      66%     442 ## 60%的请求在442ms内返回 

  • 相关阅读:
    PHP使用CURL详解
    PHP中使用sleep函数实现定时任务实例分享
    (实用篇)PHP ftp上传文件操作类
    php Pthread 多线程基本介绍
    用PHP发送POST请求
    面向对象【day08】:类的起源与metaclass(二)
    面向对象【day07】:面向对象使用场景(十)
    面向对象【day07】:知识点回顾(十一)
    面向对象【day07】:析构函数(六)
    面向对象【day07】:类的继承(七)
  • 原文地址:https://www.cnblogs.com/orlion/p/5316489.html
Copyright © 2011-2022 走看看