Eseguire benchmark con Apache Bench
Apache Bench è un tool per eseguire benchmark sul webserver Apache.
Dovrebbe essere già installato con il pacchetto apache2-utils.
In caso non lo sia, su Debian lo installate così:
# aptitude install apache2-utils
Fatto questo proviamo a lanciare un primo comando di esempio:
$ ab www.sito.it/
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 ferrons.ddns.net (be patient).....done
Server Software: Apache/2.4.38
Server Hostname: www.sito.it
Server Port: 80
Document Path: /
Document Length: 1546 bytes
Concurrency Level: 1
Time taken for tests: 0.018 seconds
Complete requests: 1
Failed requests: 0
Total transferred: 1737 bytes
HTML transferred: 1546 bytes
Requests per second: 54.41 [#/sec] (mean)
Time per request: 18.380 [ms] (mean)
Time per request: 18.380 [ms] (mean, across all concurrent requests)
Transfer rate: 92.29 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 4 4 0.0 4 4
Processing: 15 15 0.0 15 15
Waiting: 12 12 0.0 12 12
Total: 18 18 0.0 18 18
Senza opzioni non abbiamo tantissimi dati, quindi impostiamo qualche parametro:
$ ab -t 10 -n 10000 -c 100 www.sito.it/
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 www.sito.it (be patient)
Finished 302 requests
Server Software: Apache/2.4.38
Server Hostname: www.sito.it
Server Port: 80
Document Path: /
Document Length: 1546 bytes
Concurrency Level: 100
Time taken for tests: 10.003 seconds
Complete requests: 302
Failed requests: 0
Total transferred: 543681 bytes
HTML transferred: 483898 bytes
Requests per second: 30.19 [#/sec] (mean)
Time per request: 3312.241 [ms] (mean)
Time per request: 33.122 [ms] (mean, across all concurrent requests)
Transfer rate: 53.08 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 5 621 329.9 512 1267
Processing: 35 2152 725.7 2077 3837
Waiting: 30 1935 744.3 1854 3626
Total: 39 2773 637.5 2704 4432
Percentage of the requests served within a certain time (ms)
50% 2704
66% 2836
75% 3065
80% 3121
90% 3704
95% 4113
98% 4243
99% 4294
100% 4432 (longest request)
Dove:
- -t è il timeout per ogni richiesta
- -n è il numero di richieste
- -c imposta quante richieste simultanee vanno inviate
Ovviamente al posto di www.sito.it dovete impostare l'hostname messo nella configurazione di Apache.
Enjoy!
server apache apache bench apache2-utils
Commentami!