ab is a tool for benchmarking web servers. It generate large amount of concurrent requests to a web site, simulating high traffic. This helps you identify how many visitors your web server able to handle.
1 | ab -c 30 -n 10000 URL_OF_THE_SITE |
Here we generate 30 concurrent requests. Total of 10K requests are made for the benchmarking session.
ab is part of Apache, you can find more details at
https://httpd.apache.org/docs/2.4/programs/ab.html
On Debian/Ubuntu, you can install ab with
1 | apt install -y apache2-utils |
Here is a sample benchmark result. Apache vs Nginx
001 002 003 004 005 006 007 008 009 010 011 012 013 014 015 016 017 018 019 020 021 022 023 024 025 026 027 028 029 030 031 032 033 034 035 036 037 038 039 040 041 042 043 044 045 046 047 048 049 050 051 052 053 054 055 056 057 058 059 060 061 062 063 064 065 066 067 068 069 070 071 072 073 074 075 076 077 078 079 080 081 082 083 084 085 086 087 088 089 090 091 092 093 094 095 096 097 098 099 100 101 102 103 104 105 106 107 108 109 | boby@hon-pc-01:~$ ab -c 50 -n 1000 http://localhost:8080/ This is ApacheBench, Version 2.3 <$Revision: 1706008 $> 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: nginx/1.11.5 Server Hostname: localhost Server Port: 8080 Document Path: / Document Length: 21 bytes Concurrency Level: 50 Time taken for tests: 0.075 seconds Complete requests: 1000 Failed requests: 0 Total transferred: 252000 bytes HTML transferred: 21000 bytes Requests per second: 13292.75 [#/sec] (mean) Time per request: 3.761 [ms] (mean) Time per request: 0.075 [ms] (mean, across all concurrent requests) Transfer rate: 3271.26 [Kbytes/sec] received Connection Times (ms) min mean[+/-sd] median max Connect: 0 1 0.8 1 4 Processing: 1 3 1.4 2 7 Waiting: 0 2 1.5 2 7 Total: 2 4 1.2 3 7 Percentage of the requests served within a certain time (ms) 50% 3 66% 4 75% 4 80% 5 90% 5 95% 6 98% 7 99% 7 100% 7 (longest request) boby@hon-pc-01:~$ ab -c 50 -n 1000 http://localhost/ This is ApacheBench, Version 2.3 <$Revision: 1706008 $> 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: Apache/2.4.18 Server Hostname: localhost Server Port: 80 Document Path: / Document Length: 21 bytes Concurrency Level: 50 Time taken for tests: 0.687 seconds Complete requests: 1000 Failed requests: 0 Total transferred: 267000 bytes HTML transferred: 21000 bytes Requests per second: 1454.55 [#/sec] (mean) Time per request: 34.375 [ms] (mean) Time per request: 0.687 [ms] (mean, across all concurrent requests) Transfer rate: 379.26 [Kbytes/sec] received Connection Times (ms) min mean[+/-sd] median max Connect: 0 0 0.5 0 3 Processing: 2 34 129.6 4 601 Waiting: 2 34 128.8 4 600 Total: 2 34 130.0 4 602 Percentage of the requests served within a certain time (ms) 50% 4 66% 4 75% 6 80% 6 90% 7 95% 597 98% 601 99% 601 100% 602 (longest request) boby@hon-pc-01:~$ |
If you check Percentage of the requests served within a certain time (ms), you will see Nginx was able to service all requests under 7ms. With Apache, it take 597 ms or more for 95% of the 1000 request we made during the benchmark session.