ab和JMeter进行GET/POST压力测试的使用心得和比较(3)

因为测试时间不是严格相等,所以主要看平均:时间分布,ab普遍低一些。双方测试环境和测试参数都一致,不知道是不是jmeter在计算返回时间上算法不一样。平均时间,jmeter统计口径也是偏高

我留了个心眼,查询了web接口后台日志,确保了两次测试的传参是一样的,那么结果的差别只能理解为两个软件在统计口径(比如返回时件的测量标准上),以及http访问方式上有差别( 比如同样是设置10个并发,一般是理解为开10个线程去不断的请求接口,但线程的调度策略不一样,对服务器的压力不一样,返回的性能也不一样)。

GET测试对比完 , 再来对比一下POST API测试的效果:

【ab】:

#ab -t 100 -c 10 -p post_data.txt -T 'application/json' :8083/xxxxx

This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd,
Licensed to The Apache Software Foundation,

Benchmarking xxx.xxx.xxx.xxx (be patient)
Completed 5000 requests
Completed 10000 requests
Finished 12937 requests

Server Software:        CppCMS-Embedded/1.0.4
Server Hostname:        xxx.xxx.xxx.xxx
Server Port:            8083

Document Path:          /xxxxx
Document Length:        92 bytes

Concurrency Level:      10
Time taken for tests:  100.001 seconds
Complete requests:      12937
Failed requests:        0
Write errors:          0
Total transferred:      2962573 bytes
Total POSTed:          4828858
HTML transferred:      1190204 bytes
Requests per second:    129.37 [#/sec] (mean)
Time per request:      77.299 [ms] (mean)
Time per request:      7.730 [ms] (mean, across all concurrent requests)
Transfer rate:          28.93 [Kbytes/sec] received
                        47.16 kb/s sent
                        76.09 kb/s total

Connection Times (ms)
              min  mean[+/-sd] median  max
Connect:        1    2  8.9      1    1001
Processing:    31  76  78.5    69    2452
Waiting:      31  75  77.7    69    2452
Total:        33  77  79.0    71    2454

Percentage of the requests served within a certain time (ms)
  50%    71
  66%    80
  75%    88
  80%    91
  90%    101
  95%    113
  98%    124
  99%    140
 100%  2454 (longest request)

【jmeter】

而同样参数配置的jmeter的结果为:

#../apache-jmeter-2.11/bin/jmeter -n -t post.jmx -JCSV=post_paras.txt -JIP=xxx.xxx.xxx.xxx -JPORT=8083 -JTHREAD=10 -JRAMP=1 -l "post_test.log"

Creating summariser <summary>
Created the tree successfully using post_to_recommend_user_action_server.jmx
Starting the test @ Tue Nov 17 20:49:37 CST 2015 (1447764577991)
Waiting for possible shutdown message on port 4445
summary +  3978 in  21.1s =  188.5/s Avg:    51 Min:    32 Max:  1049 Err:    0 (0.00%) Active: 10 Started: 10 Finished: 0
summary +  3796 in  30.1s =  126.2/s Avg:    78 Min:    34 Max:  1596 Err:    0 (0.00%) Active: 10 Started: 10 Finished: 0
summary =  7774 in  51.1s =  152.1/s Avg:    64 Min:    32 Max:  1596 Err:    0 (0.00%)
summary +  3273 in  30.1s =  108.8/s Avg:    91 Min:    37 Max:  3091 Err:    1 (0.03%) Active: 10 Started: 10 Finished: 0
summary =  11047 in  81.1s =  136.2/s Avg:    72 Min:    32 Max:  3091 Err:    1 (0.01%)

对post_test.log进行聚合报告分析

samples: 11899 

average: 58

median: 52

90% line: 76

min: 27

max: 3091

error: 0.01%

throughout: 7.6/sec

kb/sec: 1.9

post api 压测结果对比

ab   jmeter  
完成请求数   12937   11899  
平均返回时间(ms)   77   58  
最大返回时间(ms)       3091  
最小返回时间(ms)       27  
请求时间中位数(50%<)   71   52  
90%的请求反水时间低于(ms)   101   76  
错误率(基本是超时)   0   0.01%  
QPS   129   136  

【使用对比总结】
个人体会是:

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/9afd1bf81702d976ed377af9ee16cf0e.html