ab
(ubuntu) 软件安装:
sudo apt install -y apache2-utils
-n 一共多少个请求 (-n 10000 就是发1万个请求, -n 1000000 就是发 100万的请求)
-c 多少个并发 (同时发多少个, 默认是一个, -c 5 表示同时发5个请求
Requests per second 表示每秒处理多少请求
下面
Requests per second: 3287.11
表示每秒处理3287 个请求 (这就是性能测试)
Time per request: 0.304 [ms] (mean)
表示每个请求的平均处理事件 0.304 毫秒
完整压测命令: ab -n 20000 http://127.0.0.1:8080/
curl http://127.0.0.1:8080
<html>
<head>
<title>libevent http server </title>
</head>
<body>
<h1>libevent http server start success</h1>
</body>
</html>
Usage: ab [options] [http[s]://]hostname[:port]/path
ab -n 20000 http://127.0.0.1:8080/
This is ApacheBench, Version 2.3 <$Revision: 1807734 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking 127.0.0.1 (be patient)
Completed 2000 requests
Completed 4000 requests
Completed 6000 requests
Completed 8000 requests
Completed 10000 requests
Completed 12000 requests
Completed 14000 requests
Completed 16000 requests
Completed 18000 requests
Completed 20000 requests
Finished 20000 requests
Server Software:
Server Hostname: 127.0.0.1
Server Port: 8080
Document Path: /
Document Length: 130 bytes
Concurrency Level: 1
Time taken for tests: 6.084 seconds
Complete requests: 20000
Failed requests: 0
Total transferred: 3880000 bytes
HTML transferred: 2600000 bytes
Requests per second: 3287.11 [#/sec] (mean)
Time per request: 0.304 [ms] (mean)
Time per request: 0.304 [ms] (mean, across all concurrent requests)
Transfer rate: 622.75 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.6 0 28
Processing: 0 0 0.3 0 34
Waiting: 0 0 0.3 0 34
Total: 0 0 0.6 0 34
Percentage of the requests served within a certain time (ms)
50% 0
66% 0
75% 0
80% 0
90% 0
95% 0
98% 1
99% 1
100% 34 (longest request)
)