apache ab test使用 apache ab test使用 单独安装ab和htpasswd

转载自:

http://www.cnblogs.com/super-d2/p/3831155.html#top

http://blog.chinaunix.net/uid-20382003-id-3032167.html

注意:ab test是不支持长连接压测的,只支持短连接压测

ab性能不行,会拖累nginx回包和关闭链接的延迟,最终影响整体nginx并发测试,尝试同时开多个ab发包(http://www.itzk.com/thread-583354-52-1.shtml)

单独安装ab和htpasswd

yum install -y httpd-tools

完成后,就可以直接运行ab

# which ab
/usr/bin/ab # rpm -qf /usr/bin/ab
httpd-tools-2.2.-.el6.centos..x86_64 # which htpasswd
/usr/bin/htpasswd

压测方法,一定要指定页面名

/usr/bin/ab  -n  -c  https://www.baidu.com/index.php

压测之前先执行下面命令

ulimit -n 

htpasswd加密

默认以DES加密
htpasswd -c /root/aa.txt test
# cat aa.txt
test:Dl4dQa5GI3Qzs md5和sha加密
htpasswd -c -m /root/.aa.txt user1

ab test

先查看一下版本信息 ab -V(注意是大写的V)

2、我们也可以使用小写的v查看下ab命令的一些属性 ab -v

1、命令格式
ab命令放在apache目录bin目录下面,使用方法如下

./ab -n  -c  http://www.test.com/

其中-n代表每次并发量,-c代表总共发送的数量

2、测试结果分析
[root@Svr107 bin]# ./ab -n 3000 -c 3000 http://www.test.com/
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.twioo.com (be patient)
Completed 300 requests
Completed 600 requests
Completed 900 requests
Completed 1200 requests
Completed 1500 requests
Completed 1800 requests
Completed 2100 requests
Completed 2400 requests
Completed 2700 requests
Completed 3000 requests
Finished 3000 requests

Server Software: nginx/0.7.65
Server Hostname: www.test.com
Server Port: 80

Document Path: / ###请求的资源
Document Length: 50679 bytes ###文档返回的长度,不包括页头

Concurrency Level: 3000 ###并发个数
Time taken for tests: 30.449 seconds ###总请求时间
Complete requests: 3000 ###总请求数
Failed requests: 0 ###失败的请求数
Write errors: 0
Total transferred: 152745000 bytes
HTML transferred: 152037000 bytes
Requests per second: 98.52 [#/sec] (mean) ###平均每秒的请求数
Time per request: 30449.217 [ms] (mean) ###平均每个请求消耗的时间
Time per request: 10.150 [ms] (mean, across all concurrent requests) ###上面的请求除以并发数
Transfer rate: 4898.81 [Kbytes/sec] received ###传输速率

Connection Times (ms)
min mean[+/-sd] median max
Connect: 2 54 27.1 55 98
Processing: 51 8452 5196.8 7748 30361
Waiting: 50 6539 5432.8 6451 30064
Total: 54 8506 5210.5 7778 30436

Percentage of the requests served within a certain time (ms)
50% 7778 ###50%的请求都在7778ms内完成
66% 11059
75% 11888
80% 12207
90% 13806  ###90%的请求都在13806 ms内完成
95% 18520
98% 24232
99% 24559
100% 30436 (longest request)  ###100%的请求都在30436ms内完成  大部分请求响应时间都很长

3、如果用ab访问的是本机上的web服务器,使用127.0.0.1或者是web服务器上的网卡IP地址,这个是不走网络设备的,可以忽略网络消耗

4、ab使用的一些问题
a、ab命令在一般系统上面做测试时候,一般并发不能超过1024个,其实是因为因为系统限制每个进程打开的最大文件数为1024,可以用ulimit -a来查看
open files (-n) 65536 ##这个我系统已经修改过
b、-n 可以指定最大请求数,但是不能超过50000个
c、-v n 当n>=2 时,可以显示发送的http请求头,和响应的http头及内容,压力测试时不要这么做
[root@Svr107 bin]# ./ab -n 1 -c 1 -v 2 http://www.test.com/
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.test.com (be patient)...INFO: POST header ==
---
GET / HTTP/1.0
Host: www.test.com
User-Agent: ApacheBench/2.3
Accept: */*

---
LOG: header received:
HTTP/1.1 200 OK
Server: nginx/0.7.65
Date: Thu, 01 Dec 2011 13:08:16 GMT
Content-Type: text/html
Connection: close
Vary: Accept-Encoding
Content-Length: 50515
Last-Modified: Thu, 01 Dec 2011 13:08:04 GMT
Accept-Ranges: bytes

<sc< div="">
..done

Server Software: nginx/0.7.65
Server Hostname: www.test.com
Server Port: 80

Document Path: /
Document Length: 50515 bytes

Concurrency Level: 1
Time taken for tests: 0.006 seconds
Complete requests: 1
Failed requests: 0
Write errors: 0
Total transferred: 50751 bytes
HTML transferred: 50515 bytes
Requests per second: 176.27 [#/sec] (mean)
Time per request: 5.673 [ms] (mean)
Time per request: 5.673 [ms] (mean, across all concurrent requests)
Transfer rate: 8736.39 [Kbytes/sec] received

Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.0 0 0
Processing: 5 5 0.0 5 5
Waiting: 1 1 0.0 1 1
Total: 6 6 0.0 6 6

在做压力测试的时候,一般情况下压力测试客户端接收到的数据量一定会远大于发送出去的数据量

问题

b -n 3000 -c 3000 http://192.168.0.2/
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 192.168.0.2 (be patient)
socket: Too many open files (24)

解决方法:

查看当前要以打开的文件个数

[root@zabbix ~]# ulimit -a
core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 14802
max locked memory       (kbytes, -l) 64
max memory size         (kbytes, -m) unlimited
open files                      (-n) 1024    #只能打开1024个socket文件 /端口
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) 10240
cpu time               (seconds, -t) unlimited
max user processes              (-u) 14802
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited

调整可以打开的文件数

[root@zabbix ~]# ulimit -n 65535
重新执行ab命令即可解决


自己压测结果

# /usr/bin/ab  -n 3000 -c 3000 https://www.baidu.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.baidu.com (be patient)
Completed 300 requests
Completed 600 requests
SSL handshake failed (5).
Completed 900 requests
SSL handshake failed (5).
SSL handshake failed (5).
SSL handshake failed (5).
SSL handshake failed (5).
SSL handshake failed (5).
SSL handshake failed (5).
SSL handshake failed (5).
SSL handshake failed (5).
SSL handshake failed (5).
SSL handshake failed (5).
SSL handshake failed (5).
SSL handshake failed (5).
SSL handshake failed (5).

/usr/bin/ab  -n 3000 -c 3000 https://www.baidu.com:443/index.php

/usr/bin/ab  -n 3000 -c 3000 http://www.80ops.cn/archives/178.html

/usr/bin/ab  -n 3 -c 3 http://www.80ops.cn/archives/178.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 www.80ops.cn (be patient).....done

Server Software:        nginx/1.6.3
Server Hostname:        www.80ops.cn
Server Port:            80

Document Path:          /archives/178.html
Document Length:        74117 bytes

Concurrency Level:      3
Time taken for tests:   1.092 seconds
Complete requests:      3
Failed requests:        0
Write errors:           0
Total transferred:      223206 bytes
HTML transferred:       222351 bytes
Requests per second:    2.75 [#/sec] (mean)
Time per request:       1092.167 [ms] (mean)
Time per request:       364.056 [ms] (mean, across all concurrent requests)
Transfer rate:          199.58 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:       28   30   1.3     30      31
Processing:   126  587 435.8    817     993
Waiting:       38   44   5.1     47      48
Total:        157  616 435.2    846    1022

Percentage of the requests served within a certain time (ms)
  50%    669
  66%    669
  75%   1022
  80%   1022
  90%   1022
  95%   1022
  98%   1022
  99%   1022
 100%   1022 (longest request)
You have new mail in /var/spool/mail/root

相关问题

http://blog.csdn.net/largetalk/article/details/7337102

http://2hei.net/linux_web_test_tools_for_https.html

apache ab test使用 单独安装ab和htpasswd的更多相关文章

  1. centos 单独安装apachebench

    这两天在测试php性能优化方法. 为了做压力测试可观察效果,就选择了ApacheBench来作为压力测试工具.其实就是大家常说的ab. 但是这个工具是安装apache web server的时候自带的 ...

  2. 压力测试工具ab及centos下单独安装方法 nginx和tomcat静态资源的性能测试

    Apache安装包中自带的压力测试工具Apache Benchmark(简称ab)简单易用,这里采用ab作为压国测试工具. 独立安装: ab运行需要信赖apr-util包: # yum install ...

  3. 压力测试工具ab及centos下单独安装方法

    压力测试工具Ab简介 Apache安装包中自带的压力测试工具 Apache Benchmark(简称ab) 简单易用,这里就采用 ab作为压力测试工具了. 1.独立安装 ab运行需要依赖apr-uti ...

  4. [转] CentOS单独安装Apache Benchmark压力测试工具的办法

    Apache安装包中自带的压力测试工具 Apache Benchmark(简称ab) 简单易用,这里就采用 ab作为压力测试工具了. 1.独立安装 ab运行需要依赖apr-util包,安装命令为: 1 ...

  5. Linux学习13-CentOS安装ab做压力测试

    前言 网站性能压力测试是服务器网站性能调优过程中必不可缺少的一,测试环境准备好了后,如何对网站做压力测试? 压力测试的工具很多,如:ab.http_load.webbench.siege.jmeter ...

  6. Apache自带压力测试工具ab用法简介

    ab命令原理 ab命令会创建很多的并发访问线程,模拟多个访问者同时对某一URL进行访问.它的测试目标是基于URL的,因此,既可以用来测试Apache的负载压力,也可以测试nginx.lighthttp ...

  7. 安装AB编程软件提示安装失败时如何处理

    前言:在安装Studio 5000.FT VIEW.Logxi Emulate等AB编程软件,有时会出现安装失败.在这里,根据自己在安装过程中出现的错误情形,介绍如何处理的方法. 方法步骤 1.在安装 ...

  8. win10安装ab测试工具

    1.先下载 https://www.apachehaus.com/cgi-bin/download.plx 2.存到非中文无空格的目录 3.解压,并打开配置文件:Apache24\conf\httpd ...

  9. nginx 安装ab小工具方法

    nginx 安装ab小工具方法测试工具安装(以centos系统为例)yum -y install httpd-tools 然后测试下ab -V

随机推荐

  1. 【R markdown】rmysql乱码问题

    统计数据遇到在Rmarkdown文档中通过rmysql查询中文结果乱码的现象. 数据库编码 utf8 rmd编码utf8 猜测是生成的html编码非utf8 解决方案是: dbSendQuery(co ...

  2. NGUI之scroll view的制作和踩坑总结

    之前也看了不少童鞋谢了关于NGUI的scroll view的制作下面我写下自己的制作过程以及心得,希望对童鞋们有所帮助.1.首先建立一个960*640的背景参考http://game.ceeger.c ...

  3. 如何通过phoenix中查看表的主键信息

    需求描述: 今天一个开发的同事让帮忙查看下表的主键列,在此记录下. 操作过程: 1.通过!primarykeys命令查看表的主键 !primarykeys SYNC_BUSINESS_INFO_BYD ...

  4. mysqlbinlog基于某个偏移量进行数据的恢复(重做),--start-position,--stop-position的使用方法

    需求描述: 今天在看mysqlbinlog的内容,看到了--start-position和--stop-position这些选项, 就测试下这个参数具体该怎么进行使用呢,在此记录下. 操作过程: 1. ...

  5. Codeforces-475B Strongly Connected City

    仅仅用推断最外层是不是回路  假设是   则每两个点之间连通 #include<iostream> #include<algorithm> #include<cstdio ...

  6. ASP------字符串与HTML格式相互转换

    代码: 1.字符串转HTML HttpUtility.HtmlDecode(" is ") 或者 Server.UrlDecode(" is ") 2.HTML ...

  7. POJ 2923 Relocation(01背包变形, 状态压缩DP)

    Q: 如何判断几件物品能否被 2 辆车一次拉走? A: DP 问题. 先 dp 求解第一辆车能够装下的最大的重量, 然后计算剩下的重量之和是否小于第二辆车的 capacity, 若小于, 这 OK. ...

  8. swift--使用 is 和 as 操作符来实现类型检查和转换 / AnyObject与Any的区别

    声明几个类: //动物类 class Animal{ } //陆地动物类 class terricole: Animal { } //海洋动物类 class SeaAnimals: Animal { ...

  9. 《C#高级编程》学习笔记------抗变和协变

    1.协变和抗变 在.NET 4之前,泛型接口是不变的..NET 4通过协变和抗变为泛型接口和泛型委托添加了一个重要的扩展.协变和抗变指对参数和返回值的类型进行转换.例如,可以给一个需要Shape参数的 ...

  10. SPF难以解决邮件伪造的现状以及方案

    邮件伪造的现状 仿冒域名 私搭邮服仿冒域名: 例如某公司企业的域名是example.com,那么攻击者可以搭建一个邮服,也把自己的域名配置为example.com,然后发邮件给真实的企业员工xxx@e ...