- 压力测试
使用apache自带的压力测试软件Apache Benchmark(ab)使用示例
进入到apache的bin目录执行以下命令API压测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
39D:\phpstudy_pro\Extensions\Apache2.4.39\bin>ab -n100 -c10 http://www.baidu.com/
#-n为请求数,-c为并发数
This is ApacheBench, Version 2.3 <$Revision: 1843412 $>
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).....done
Server Software: BWS/1.1 #服务器版本
Server Hostname: www.baidu.com #域名
Server Port: 80 #端口
Document Path: / #请求url
Document Length: 293986 bytes #文档大小
Concurrency Level: 10 #并发数
Time taken for tests: 5.699 seconds #总耗时
Complete requests: 100 #完成请求数
Failed requests: 98 #失败请求数
(Connect: 0, Receive: 0, Length: 98, Exceptions: 0)
Total transferred: 29497704 bytes #总共传输字节数,包含http的头信息等
HTML transferred: 29382788 bytes #html字节数,实际的页面传递字节数
Requests per second: 17.55 [#/sec] (mean) #每秒多少请求,这个是非常重要的参数数值,服务器的吞吐量
Time per request: 569.924 [ms] (mean) #用户平均请求等待时间
Time per request: 56.992 [ms] (mean, across all concurrent requests) #服务器平均处理时间,也就是服务器吞吐量的倒数
Transfer rate: 5054.42 [Kbytes/sec] received #每秒获取的数据长度
Connection Times (ms) #连接的最小时间,平均值,中值,最大值
min mean[+/-sd] median max
Connect: 15 53 21.5 48 121 #连接时间
Processing: 187 488 93.5 507 824 #处理时间
Waiting: 16 100 47.6 90 262 #等待时间
Total: 232 541 97.0 556 858 #合计时间
Percentage of the requests served within a certain time (ms)
50% 556 # 50%的请求在556ms内返回
66% 590 # 66%的请求在590ms内返回
75% 601
80% 605
90% 619
95% 632
98% 798
99% 858
100% 858 (longest request)1
2#params.txt文件里面的Json格式的UTF-8编码
./ab -n 500 -c 100 -p 'params.txt' -T 'application/json;charset=utf-8' http://192.1url:/fsfa/tatement
php压力测试
|