• 使用apache的ab对页面进行压力测试


    ab是apache自带的一个很好用的压力测试工具,当安装完apache的时候,就可以在bin下面找到ab

    我们可以模拟100个并发用户,对一个页面发送1000个请求

    ./ab -n1000 -c100 http://www.cnblogs.com/pick/

    其中-n代表请求数,-c代表并发数( 详细参数可以用ab --help 查看)

    返回结果:

    ##首先是apache的版本信息 

    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.cnblogs.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
    Completed 900 requests
    Completed 1000 requests
    Finished 1000 requests


    Server Software:
    Server Hostname: www.cnblogs.com
    Server Port: 80

    Document Path: /pick/
    Document Length: 40990 bytes

    Concurrency Level: 100  ##并发数 
    Time taken for tests: 8.385 seconds  ##共使用了多少时间 
    Complete requests: 1000   ##请求数 
    Failed requests: 616      ##失败请求 
    (Connect: 0, Receive: 0, Length: 616, Exceptions: 0)
    Write errors: 0
    Total transferred: 41420957 bytes  ##总共传输字节数,包含http的头信息等 
    HTML transferred: 41111501 bytes  ##html字节数,实际的页面传递字节数 
    Requests per second: 119.27 [#/sec] (mean)  ##每秒多少请求,这个是非常重要的参数数值,服务器的吞吐量 
    Time per request: 838.456 [ms] (mean)  ##用户平均请求等待时间 
    Time per request: 8.385 [ms] (mean, across all concurrent requests)  ##服务器平均处理时间,也就是服务器吞吐量的倒数 
    Transfer rate: 4824.36 [Kbytes/sec] received   ##每秒获取的数据长度

    Connection Times (ms)
          min    mean[+/-sd]   median   max
    Connect:    24     225   532.6       29        7028
    Processing: 50    396   916.4    88      6164
    Waiting:     25    133   473.9    31      3040
    Total:     75    621   1095.1   129     7196

    Percentage of the requests served within a certain time (ms)
    50% 129  ## 50%的请求在129ms内返回
    66% 164  ## 66%的请求在164ms内返回 
    75% 401
    80% 1102
    90% 1675
    95% 3435
    98% 4130
    99% 4160
    100% 7196 (longest request)

    说明:考虑到带宽不在测试的范围,ab压力测试应该在内网测试。

  • 相关阅读:
    DLL相关注意
    给我个理由要用虚析构函数
    字符指针常量和字符数组
    给自己普及网络基本知识
    面向对象三大基本特性,五大基本原则
    C/C++内存区域划分
    C++多态性
    Java XML Schema详解
    Java SE 第一百零五讲 对象的克隆与浅拷贝
    Java SE 第九十七~一百零五讲 线程与进程
  • 原文地址:https://www.cnblogs.com/cqingt/p/6043207.html
Copyright © 2020-2023  润新知