Ija*_*han 1 linux performance apache-httpd
我如何轻松测试我的 Web 服务器 (Apache) 设置可以处理多少请求而不会断开连接或超时。
是否有任何简单的 bash 脚本,或者我必须使用一些复杂的压力测试工具。
小智 5
您可以使用ab位于 package.json 中的软件进行测试apache2-utils。例子:
ab -r -n 100 -c 10 -k -H "Accept-Encoding: gzip, deflate" http://mysite.mydomain.com/
Run Code Online (Sandbox Code Playgroud)
-r:避免在套接字错误时退出。 -n:要执行的请求数。-c:并发运行的多个请求的数量。-k:启用 HTTP KeepAlive。意味着它将在每个 Http 会话中执行多个请求。-H: 自定义标题。这在很大程度上取决于您的站点的配置方式。这是我在一个只有索引页(php)的简单站点中进行的测试的结果:
# ab -r -n 200 -c 20 -k -H "Accept-Encoding: gzip, deflate" http://intranet.example.com/
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking intranet.example.com (be patient)
Completed 100 requests
Completed 200 requests
Finished 200 requests
Server Software: Apache/2.2.15
Server Hostname: intranet.example.com
Server Port: 80
Document Path: /
Document Length: 10276 bytes
Concurrency Level: 20
Time taken for tests: 38.344 seconds
Complete requests: 200
Failed requests: 0
Write errors: 0
Keep-Alive requests: 0
Total transferred: 2132800 bytes
HTML transferred: 2055200 bytes
Requests per second: 5.22 [#/sec] (mean)
Time per request: 3834.421 [ms] (mean)
Time per request: 191.721 [ms] (mean, across all concurrent requests)
Transfer rate: 54.32 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.1 0 1
Processing: 2869 3813 383.1 3649 5205
Waiting: 2868 3781 380.4 3613 5161
Total: 2869 3814 383.1 3650 5205
Percentage of the requests served within a certain time (ms)
50% 3650
66% 3763
75% 3971
80% 4318
90% 4451
95% 4530
98% 4634
99% 5093
100% 5205 (longest request)
Run Code Online (Sandbox Code Playgroud)
但是,您必须在两次测试之间花一些时间,确保您的 httpd 服务没有承受过重的负载,并增加所有参数以增加对服务器的影响。据我所知,没有任何工具可以评估此输出并即时增加性能测量参数。
链接: