标签:哪些 oca ice 简单的 com ab测试 测试 两台 目标
在学习ab工具之前,我们需了解几个关于压力测试的概念
吞吐率(Requests per second)
概念:服务器并发处理能力的量化描述,单位是reqs/s,指的是某个并发用户数下单位时间内处理的请求数。某个并发用户数下单位时间内能处理的最大请求数,称之为最大吞吐率。
计算公式:总请求数 / 处理完成这些请求数所花费的时间,即
Request per second = Complete requests / Time taken for tests
并发连接数(The number of concurrent connections)
概念:某个时刻服务器所接受的请求数目,简单的讲,就是一个会话。
并发用户数(The number of concurrent users,Concurrency Level)
概念:要注意区分这个概念和并发连接数之间的区别,一个用户可能同时会产生多个会话,也即连接数。
用户平均请求等待时间(Time per request)
计算公式:处理完成所有请求数所花费的时间/ (总请求数 / 并发用户数),即
Time per request = Time taken for tests /( Complete requests / Concurrency Level)
服务器平均请求等待时间(Time per request: across all concurrent requests)
计算公式:处理完成所有请求数所花费的时间 / 总请求数,即
Time taken for / testsComplete requests
可以看到,它是吞吐率的倒数。
同时,它也=用户平均请求等待时间/并发用户数,即
Time per request / Concurrency Level
简单了解下ab
ab全程是apache benchmark,是apache官方推出的一个工具,创建多个并发访问线程,模拟多个访问者同时对一个URL地址进行访问。它的测试目标是基于URL的,因此它既可以来测试apache的负载压力,也可以测试Nginx等服务器的压力。
ab压力测试需要注意哪些?
测试的注意事项:
测试机器与被测试机器要分开,别在同一台机器上测试,否则结果是不准确的
不要对线上的服务器做测试,否则挂了就不好了哦。
观察测试工具ab所在的机器,以及被测试的前端机器的CPU,内存,网络等都不超过最高限度的75%。
下面测试下,两台服务器。
192.168.136.135 作为被测试的WEB服务器
192.168.136.148 作为ab测试的服务器
首先确保ab测试服务器安装ab,使用以下命令yum安装
-
yum -y install httpd-tools
-
查看信息:ab -V
安装完成之后,执行ab命令,返回一些帮助信息,确保安装成功
访问以下被测试的服务器,确保正常
执行下面的命令进行测试
ab -c 100 -n 5000 http:
返回的结果
-
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
-
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http:
-
Licensed to The Apache Software Foundation, http:
-
-
Benchmarking 192.168.136.135 (be patient)
-
Completed 500 requests
-
Completed 1000 requests
-
Completed 1500 requests
-
Completed 2000 requests
-
Completed 2500 requests
-
Completed 3000 requests
-
Completed 3500 requests
-
Completed 4000 requests
-
Completed 4500 requests
-
Completed 5000 requests
-
Finished 5000 requests
-
-
-
Server Software: nginx
-
Server Hostname: 192.168.136.135
-
Server Port: 80
-
-
Document Path: /phpinfo.php
-
Document Length: 96660 bytes
-
-
Concurrency Level: 100
-
Time taken for tests: 11.860 seconds
-
Complete requests: 5000
-
Failed requests: 486
-
(Connect: 0, Receive: 0, Length: 486, Exceptions: 0)
-
Write errors: 0
-
Total transferred: 484274801 bytes
-
HTML transferred: 483509342 bytes
-
Requests per second: 421.60 [#/sec] (mean)
-
Time per request: 237.194 [ms] (mean)
-
Time per request: 2.372 [ms] (mean, across all concurrent requests)
-
Transfer rate: 39876.53 [Kbytes/sec] received
-
-
Connection Times (ms)
-
min mean[+/-sd] median max
-
Connect: 0 1 1.3 1 13
-
Processing: 45 234 44.2 231 540
-
Waiting: 23 187 40.7 182 442
-
Total: 47 235 44.0 232 540
-
-
Percentage of the requests served within a certain time (ms)
-
50% 232
-
66% 238
-
75% 243
-
80% 247
-
90% 280
-
95% 302
-
98% 382
-
99% 442
-
100% 540 (longest request)
把并发数改为50测试一下
ab -c 50 -n 5000 http:
-
-
-
min mean[+/-sd] median max
-
-
Processing: 52 104 13.2 104 158
-
Waiting: 36 79 8.1 79 135
-
Total: 65 105 13.3 104 170
-
-
Percentage of the requests served within a certain time (ms)
-
-
-
-
-
-
-
-
-
100% 170 (longest request)
-
[root@localhost ~]# ab -c 50 -n 5000 http:
-
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
-
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http:
-
Licensed to The Apache Software Foundation, http:
-
-
Benchmarking 192.168.136.135 (be patient)
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Server Hostname: 192.168.136.135
-
-
-
Document Path: /phpinfo.php
-
Document Length: 96660 bytes
-
-
-
Time taken for tests: 10.987 seconds
-
-
-
(Connect: 0, Receive: 0, Length: 478, Exceptions: 0)
-
-
Total transferred: 484064467 bytes
-
HTML transferred: 483299467 bytes
-
Requests per second: 455.07 [#/sec] (mean)
-
Time per request: 109.874 [ms] (mean)
-
Time per request: 2.197 [ms] (mean, across all concurrent requests)
-
Transfer rate: 43023.80 [Kbytes/sec] received
-
-
-
min mean[+/-sd] median max
-
-
Processing: 32 109 14.4 108 192
-
Waiting: 9 82 10.1 83 158
-
Total: 32 109 14.3 109 193
-
-
Percentage of the requests served within a certain time (ms)
-
-
-
-
-
-
-
-
-
100% 193 (longest request)
测试结果其实并不实际很准确,因为测试机和被测试机都在一台机器上。这里值是了解。
然后再来一个静态的html测试下
转载:https://blog.csdn.net/weixin_41981080/article/details/86742830
简单模拟一下ab压力测试
标签:哪些 oca ice 简单的 com ab测试 测试 两台 目标
原文地址:https://www.cnblogs.com/hfdp/p/12356224.html