O'Reilly logo

Web Performance Tuning, 2nd Edition by Patrick Killelea

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Hits per Second

Here is a little Perl script you can run against your log file to generate a hits per second distribution over the day. You can download it from http://patrick.net/software/hps.pl. Be aware that response times get recorded when the response finishes, not when it starts, so the hits per second you see are responses completed in that second, not how many simultaneous requests you received.

#!/usr/local/bin/perl

$\ = "\n";

while(<>) {
    /(:\d\d:\d\d:\d\d)/;  # hour min second
    #/(:\d\d:\d\d):\d\d/; # or use this match for hits per minute

    $key = $1;

    $key =~ s/:/ /g;      # remove ":" so gnuplot can digest output

    $bucket{$key}++;      # add a hit to the bucket for that second
}

foreach $key (sort keys %bucket) {
    print $key, " ", $bucket{$key};
}

Once you have the output from that, say in a file called out, you can plot it with the following gnuplot configuration file. You can download it from http://patrick.net/software/hps.gp.

set term png color
set output "hps.gif"
set xdata time
set timefmt "%H %M %S"
set xrange ["00:00":"23:59"]
set ylabel "hits per second"
plot "out" using 1:4 notitle with lines

Figure 6-3 contains some example output.

Hits per second throughout the day

Figure 6-3. Hits per second throughout the day

Variable Load and Queue Length

A sudden burst of activity can cause a large backup in your processing. To see why, consider a system that is receiving one request per second and takes one second to handle ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required