欢迎来到 黑吧安全网 聚焦网络安全前沿资讯,精华内容,交流技术心得!

使用Apache的ab工具进行压力测试

来源:本站整理 作者:佚名 时间:2014-04-25 TAG:Apache 压力测试 我要投稿

 Apache附带的ab工具(本机使用的PHP环境是WAMP集成环境,ab工具位于D:\wamp\bin\apache\Apache2.2.21\bin)非常容易使用,ab可以直接在Web服务器本地发起测试请求,这至关重要,因为有些时候我们需要测试的仅仅是服务器的处理性能,并不想掺杂着网络传输时间的影响。ab进行一切测试的本质都是基于HTTP的,所以可以说ab对于Web服务器软件的黑盒性能测试,获得的一切数据和计算结果,都是可以通过HTTP来解释的。

测试本机是否正确安装ab工具,在power shell想将当前目录定位到bin,输入   .\ab –V 命令,如果安装正确,则会将其版本信息打印出来。

PS D:\wamp\bin\apache\Apache2.2.21\bin> .\ab -V
This is ApacheBench, Version 2.3 <$Revision: 655654 $> Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech
Licensed to The Apache Software Foundation, <a href="http://www.apache.org/">http://www.apache.org/</a>

好了,一切就绪,下面提供一个压力测试的实例:

输入命令 PS D:\wamp\bin\apache\Apache2.2.21\bin> .\ab -n1000 -c10 http://localhost/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 localhost (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:        Apache/2.2.21 Server Hostname:        localhost
Server Port: 80 Document Path:          /index.php
Document Length: 211 bytes
 
Concurrency Level: 10 Time taken for tests: 0.496 seconds
Complete requests: 1000 Failed requests: 0 Write errors: 0 Non-2xx responses: 1000 Total transferred: 400000 bytes
HTML transferred: 211000 bytes
Requests per second: 2015.93 [#/sec] (mean) Time per request: 4.960 [ms] (mean)
Time per request: 0.496 [ms] (mean, across all concurrent requests)
Transfer rate: 787.47 [Kbytes/sec] received
 
Connection Times (ms)
              min  mean[+/-sd] median   max
Connect: 0 0 0.4 0 1 Processing: 2 5 1.1 4 12 Waiting: 2 4 1.1 4 12 Total: 2 5 1.1 5 12 Percentage of the requests served within a certain time (ms) 50% 5 66% 5 75% 5 80% 6 90% 6 95% 7 98% 8 99% 9 100% 12 (longest request)

下面开始解析这条命令语句:启动ab,并出入三个参数( PS D:\wamp\bin\apache\Apache2.2.21\bin> .\ab -n1000 -c10http://localhost/index.php)

-n1000 表示请求总数为1000

-c10 表示并发用户数为10

http://localhost/index.php 表示这写请求的目标URL

测试结果也一目了然,测试出的吞吐率为: Requests per second: 2015.93 [#/sec] (mean)  初次之外还有其他一些信息。

Server Software 表示被测试的Web服务器软件名称

Server Hostname 表示请求的URL主机名

Server Port 表示被测试的Web服务器软件的监听端口

[1] [2]  下一页

【声明】:黑吧安全网(http://www.myhack58.com)登载此文出于传递更多信息之目的,并不代表本站赞同其观点和对其真实性负责,仅适于网络安全技术爱好者学习研究使用,学习中请遵循国家相关法律法规。如有问题请联系我们,联系邮箱admin@myhack58.com,我们会在最短的时间内进行处理。
  • 最新更新
    • 相关阅读
      • 本类热门
        • 最近下载