Linux命令之ab(压力测试命令)

  ab命令被集成到了httpd服务器中,所以想要使用ab命令需要先安装httpd服务。yum -y install httpd

(1).ab命令的使用方法和常用选项

ab [选项] [http[s]://]hostname[:port]/path

常用选项:

1
2
-n requests     在测试会话中所执行的请求总个数,默认一个
-c concurrency  一次产生的请求个数,默认一个

(2).实例

  测试会话总共产生1000个请求,一次生成,压力测试

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
[root@youxi2 ~]# ab -n 1000 -c 1000 http://192.168.5.102/index.html
This is ApacheBench, Version 2.3 <$Revision: 1430300 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
 
Benchmarking 192.168.5.102 (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.4.6  //被测试的httpd服务器版本
Server Hostname:        192.168.5.102  //服务器主机名
Server Port:            80  //服务器端口
 
Document Path:          /index.html  //测试的页面文档
Document Length:        7 bytes  //测试的文档大小
 
Concurrency Level:      1000  //并发数
Time taken for tests:   0.983 seconds  //整个测试时间
Complete requests:      1000  //完成请求个数
Failed requests:        0  //失败请求个数
Write errors:           0
Total transferred:      265000 bytes  //整个测试过程中总传输字节数
HTML transferred:       7000 bytes  //整个测试过程中HTML传输字节数
Requests per second:    1017.58 [#/sec] (mean)  //每秒处理请求数,mean表示这是一个平均值
Time per request:       982.726 [ms] (mean)  //平均请求时间,mean表示这是一个平均值
Time per request:       0.983 [ms] (mean, across all concurrent requests)  //每个请求实际运行时间的平均值,mean表示这是一个平均值
Transfer rate:          263.34 [Kbytes/sec] received  //传输速率
 
Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0   40  50.5      0     127
Processing:     8  178 257.1     45     839
Waiting:        8  178 257.2     45     839
Total:         34  218 294.6     47     934
 
Percentage of the requests served within a certain time (ms)
  50%     47
  66%    112
  75%    349
  80%    541
  90%    919
  95%    928
  98%    931
  99%    933
 100%    934 (longest request)

  注意:测试上限一般是由打开文件的数量决定的,这个数值可以通过ulimit -a或ulimit -n命令查看,默认大小为1024。解决办法就是ulimit -n [数值],来提高打开文件的数量上限,测试和被测试的都要提升。

posted @   苦逼运维  阅读(8527)  评论(0编辑  收藏  举报
编辑推荐:
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· .NET Core 中如何实现缓存的预热?
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 如何调用 DeepSeek 的自然语言处理 API 接口并集成到在线客服系统
· 【译】Visual Studio 中新的强大生产力特性
历史上的今天:
2018-07-18 Linux命令之free
2018-07-18 Linux命令之top
点击右上角即可分享
微信分享提示