• Web性能压力测试工具ApacheBench(ab)


        ApacheBench是apache自带的ab程序,可以实现对Apache或其他web服务器的性能压力测试。

        ab会并发创建很多个现成来模拟多个用户同时对url进行访问。ab命令对发出负载的计算机要求很低,既不会占用很高CPU,也不会占用很多内存,但却会给目标服务器造成巨大的负载。

        常用的命令格式举例:

            ab -n 5000 -c 1000 url

        -n后面的4000代表总共发出4000个请求;-c后面的1000表示采用1000个并发(模拟1000个人同时访问),后面的网址表示测试的目标URL。

        

        执行结果:

    07:29 [root@IP]$ ab -n 2000 -c 100 http://www.xxx.com/a/id_XMTM5NDY0.html
    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 ding.youku.com (be patient)
    Completed 200 requests
    Completed 400 requests
    Completed 600 requests
    Completed 800 requests
    Completed 1000 requests
    Completed 1200 requests
    Completed 1400 requests
    Completed 1600 requests
    Completed 1800 requests
    Completed 2000 requests
    Finished 2000 requests
    
    
    Server Software: nginx
    Server Hostname: ding.youku.com
    Server Port: 80
    
    Document Path: /a/id_XMTM5NDY0.html
    Document Length: 17412 bytes
    
    Concurrency Level: 100
    Time taken for tests: 2.268 seconds
    Complete requests: 2000
    Failed requests: 2
    (Connect: 0, Receive: 0, Length: 2, Exceptions: 0)
    Write errors: 0
    Non-2xx responses: 2
    Total transferred: 35543234 bytes
    HTML transferred: 34817778 bytes
    Requests per second: 881.67 [#/sec] (mean)
    Time per request: 113.421 [ms] (mean)            concurrency *timetaken * 1000 / done
    Time per request: 1.134 [ms] (mean, across all concurrent requests)    timetaken * 1000 / done
    Transfer rate: 15301.47 [Kbytes/sec] received
    
    Connection Times (ms)
    min mean[+/-sd] median max
    Connect: 2 4 2.9 3 21
    Processing: 25 70 184.8 30 2050
    Waiting: 22 38 82.4 25 1225
    Total: 27 74 186.3 32 2070
    
    Percentage of the requests served within a certain time (ms)
    50% 32
    66% 34
    75% 35
    80% 37
    90% 42
    95% 267
    98% 781
    99% 1182
    100% 2070 (longest request)

        网络环境对测试结果影响比较大,单台服务器情况下在本机测试,或者在局域网中对服务器集群进行测试,结果会更准确一些。

    如有疑问欢迎随时讨论,请大家多指点,谢谢!

  • 相关阅读:
    layout_alignStar 与 android:layout_alignEnd
    Java学习过程中的一些知识点
    L1-054 福到了->团体程序设计天梯赛-练习集
    JS冒号的作用
    JS中(function(){xxx})(); 这种写法是什么意思?
    去除vue上方的60px空白
    vue-cli · Failed to download repo vuejs-templates/webpaack: Response code 404
    Windows 7 MBR的修复与Linux产品正确卸载
    折腾一天安装Centos7,以及后面恢复Win7引导的曲折历程
    Windows 7硬盘安装CentOS 6.4 双系统 (WIN7下硬盘安装Linux(Fedora 16,CentOS 6.2,Ubuntu 12.04))
  • 原文地址:https://www.cnblogs.com/xueyanjie/p/apache_bench.html
Copyright © 2020-2023  润新知