【高并发】如何使用ab进行并发与压力测试?
【摘要】 今天给大家分享一篇如何使用ab进行并发与压力测试的文章,好了,不多说了,进入今天的正题吧。
大家好,我是冰河~~
今天给大家分享一篇如何使用ab进行并发与压力测试的文章,好了,不多说了,进入今天的正题吧。
工具使用示例如下:
ab -n 1000 -c 50 http://localhost:8080/test
命令说明如下:
- ab:ab命令;
- n:总请求次数;
- c:并发数
运行示例如下:
[root@localhost] ab -n 1000 -c 50 http://localhost:8080/test
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 localhost (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:
Server Hostname: localhost
Server Port: 8080
Document Path: /test
Document Length: 4 bytes
Concurrency Level: 50
Time taken for tests: 0.792 seconds
Complete requests: 1000
Failed requests: 0
Total transferred: 136000 bytes
HTML transferred: 4000 bytes
Requests per second: 1262.90 [#/sec] (mean)
Time per request: 39.591 [ms] (mean)
Time per request: 0.792 [ms] (mean, across all concurrent requests)
Transfer rate: 167.73 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.7 0 12
Processing: 3 38 26.0 31 186
Waiting: 2 26 21.5 23 175
Total: 3 38 26.0 32 186
Percentage of the requests served within a certain time (ms)
50% 32
66% 36
75% 42
80% 44
90% 60
95% 85
98% 151
99% 156
100% 186 (longest request)
返回结果数据说明如下:
- Concurrency Level: 并发量
- Time taken for tests: 整个测试的时间
- Complete requests: 完成的总请求数
- Failed requests: 失败的请求数
- Total transferred: 响应数据的总长度(包括http头信息和消息体数据)
- HTML transferred: 响应数据中消息体数据的总和
- Requests per second:吞吐率(计算方式为:Complete requests / Time taken for tests,也就是 完成的总请求数 / 整个测试的时间)
- Time per request: 用户平均请求等待时间
- Time per request: 服务器平均请求等待时间
- Transfer rate: 单位时间内从服务器获取的数据长度(计算方式为:Total transferred / Time taken for tests, 也就是 响应数据的总长度(包括http头信息和消息体数据)/ 整个测试的时间)
好了,今天我就简单介绍下ab的基本使用吧,今天就到这儿吧,我是冰河,我们下期见~~
【版权声明】本文为华为云社区用户原创内容,转载时必须标注文章的来源(华为云社区)、文章链接、文章作者等基本信息, 否则作者和本社区有权追究责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱:
cloudbbs@huaweicloud.com
- 点赞
- 收藏
- 关注作者
评论(0)