ab -n 9000 -c 900 localhost:8080/index.php

benchmark web server with apache benchmarking tool

-n 9000 : Number of requests to perform for the benchmarking session -c 900 : Number of multiple requests to perform at a time
Sample Output
 Completed 900 requests
 Completed 1800 requests
 Completed 2700 requests
 Completed 3600 requests
 Completed 4500 requests
 Completed 5400 requests
 Completed 6300 requests
 Completed 7200 requests
 Completed 8100 requests
 Finished 9000 requests
 
 
 Server Software:        Apache/2.0.55
 Server Hostname:        localhost
 Server Port:            8080
 
 Document Path:          /index.php
 Document Length:        37949 bytes
 
 Concurrency Level:      10
 Time taken for tests:   407.890625 seconds
 Complete requests:      9000
 Failed requests:        25
    (Connect: 0, Length: 25, Exceptions: 0)
 Write errors:           0
 Total transferred:      342093375 bytes
 HTML transferred:       340598850 bytes
 Requests per second:    22.06 [#/sec] (mean)
 Time per request:       453.212 [ms] (mean)
 Time per request:       45.321 [ms] (mean, across all concurrent requests)
 Transfer rate:          819.03 [Kbytes/sec] received
 
 Connection Times (ms)
               min  mean[+/-sd] median   max
 Connect:        0    0   2.7      0      78
 Processing:   140  452 217.8    359    2265
 Waiting:       31  402 194.0    328    2218
 Total:        140  452 218.0    359    2265
 
 Percentage of the requests served within a certain time (ms)
   50%    359
   66%    390
   75%    421
   80%    515
   90%    750
   95%    968
   98%   1156
   99%   1281
  100%   2265 (longest request)

10
By: amaymon
2009-08-07 07:19:40

These Might Interest You

  • In certain cases you mighy need to monitor the server load caused by certain process. For example HTTP, while stress testing apache using ab (apache benchmark) you may want to monitor the server status,load, # of spawned HTTP processes, # of established connections, # of connections in close wait state, apache memory footprint etc. Show Sample Output


    2
    watch -n1 "uptime && ps auxw|grep http|grep -v grep | grep -v watch|wc -l && netstat -ntup|grep :80 |grep ESTABLISHED|wc -l && netstat -ntup|grep :80|grep WAIT|wc -l && free -mo && ps -ylC httpd --sort:rss|tail -3|awk '{print \$8}'"
    rockon · 2012-06-06 12:12:10 1
  • the good: Server: Apache/2.2.8 (Ubuntu) PHP/5.2.4-2ubuntu5.4 with Suhosin-Patch the bad: Server: Microsoft-IIS/6.0 and the ugly: Server: Apache/2.2.10 (Win32) mod_ssl/2.2.10 OpenSSL/0.9.8i PHP/5.2.6


    8
    wget -S -O/dev/null "INSERT_URL_HERE" 2>&1 | grep Server
    asmoore82 · 2009-03-09 06:54:54 1
  • This is a quick and dirty way to generate a (non-floating-point) CPU-bound task to benchmark. Adjust "20" to higher or lower values, as needed. As a benchmark this is probably a little less bogus than bogomips, and it will run anywhere 'bc' does. Show Sample Output


    2
    echo '2^2^20' | time bc > /dev/null
    mkc · 2009-02-06 02:31:55 1
  • Benchmark a SQL query against MySQL Server. The example runs the query 10 times, and you get the average runtime in the output. To ensure that the query does not get cached, use `RESET QUERY CACHE;` on top in the query file. Show Sample Output


    0
    perf stat -r 10 sh -c "mysql > /dev/null < query.sql"
    particleflux · 2018-05-03 12:20:03 0
  • See: http://imgur.com/JgjK2.png for example. Do some serious benchmarking from the commandline. This will write to a file with the time it took to compress n bytes to the file (increasing by 1). Run: gnuplot -persist <(echo "plot 'lzma' with lines, 'gzip' with lines, 'bzip2' with lines") To see it in graph form.


    3
    for a in bzip2 lzma gzip;do echo -n>$a;for b in $(seq 0 256);do dd if=/dev/zero of=$b.zero bs=$b count=1;c=$(date +%s%N);$a $b.zero;d=$(date +%s%N);total=$(echo $d-$c|bc);echo $total>>$a;rm $b.zero *.bz2 *.lzma *.gz;done;done
    matthewbauer · 2009-10-20 01:00:51 2
  • This let you know which modules has loaded the Apache server, very useful to know if the mod_rewrite is ready to use. Show Sample Output


    5
    apache2 -t -D DUMP_MODULES
    ElAlecs · 2009-02-16 17:30:20 2

What Others Think

One fantastic contribution!
linuxrawkstar · 458 weeks and 4 days ago

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands



Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: