As always, your users are complaining "the web site is too slow! We're dying here!" But it seems OK to you. Isn't there some way you can make some objective measurements without having to master some expensive, complicated analysis tool?
While sophisticated HTTP server analysis tools are nice, and there are dozens of them, sometimes you just want something quick and easy. httping is an excellent utility for measuring HTTP server throughput and latency, and because it's a tiny command-line tool, you can easily run it from multiple locations via SSH.
Its simplest invocation is to test latency:
$ httping -c4 -g http://www.oreilly.com
PING www.oreilly.com:80 (http://www.oreilly.com):
connected to www.oreilly.com:80, seq=0 time=177.37 ms
connected to www.oreilly.com:80, seq=1 time=170.28 ms
connected to www.oreilly.com:80, seq=2 time=165.71 ms
connected to www.oreilly.com:80, seq=3 time=179.51 ms
--- http://www.oreilly.com ping statistics ---
4 connects, 4 ok, 0.00% failed
round-trip min/avg/max = 165.7/173.2/179.5 ms
That's not too bad. This doesn't tell you how long it takes
pages to load, only how long it takes the server to respond to a HEAD
request, which means fetching only the page headers without the
content. So, let's do a GET (-G
)
request, which fetches the whole page:
$ httping -c4 -Gg http://www.oreilly.com
PING www.oreilly.com:80 (http://www.oreilly.com):
connected to www.oreilly.com:80, seq=0 time=1553.78 ms
connected to www.oreilly.com:80, seq=1 time=2790.99 ms
connected to www.oreilly.com:80, seq=2 time=2067.32 ms
connected to www.oreilly.com:80, seq=3 time=2033.02 ms
--- http://www.oreilly.com ping statistics ---
4 connects, 4 ok, 0.00% failed
round-trip min/avg/max = 1553.8/2111.3/2791.0 ms
That slowed it down a bit!
The -r
switch tells
httping to resolve the hostname only once, to
remove DNS latency from its measurements:
$ httping -c4 -Grg http://www.oreilly.com
You can test SSL-enabled sites with the -l
switch:
$ httping -c4 -lGg https://www.fictionalsslsite.org
To specify an alternate port, append it to the URL:
$ httping -c4 -Gg http://www.fictionalsslsite.org:8080
httping will report the roundtrip time with
the -b
switch in kilobytes per
second (not kilobits):
$ httping -c4 -Gbg http://www.fictionalsslsite.org
PING www.fictionalsslsite.org:80 (http://www.fictionalsslsite.org):
connected to www.fictionalsslsite.org:80, seq=0 time=2553.96 ms 43KB/s
Use the -s
switch to display
return codes. Put it all together, and this is what you get:
$ httping -c4 -Gsbrg http://www.oreilly.com
PING www.oreilly.com:80 (http://www.oreilly.com):
75KB/sed to www.oreilly.com:80, seq=0 time=1567.91 ms 200 OK
72KB/sed to www.oreilly.com:80, seq=1 time=1618.20 ms 200 OK
18KB/sed to www.oreilly.com:80, seq=2 time=5869.12 ms 200 OK
58KB/sed to www.oreilly.com:80, seq=3 time=1979.43 ms 200 OK
--- http://www.oreilly.com ping statistics ---
4 connects, 4 ok, 0.00% failed
round-trip min/avg/max = 1567.9/2758.7/5869.1 ms
Transfer speed: min/avg/max = 18/56/75 KB
You can test a local server by specifying the hostname and port instead of the URL:
$ httping -c4 -h xena -p 80
Ubuntu Feisty ships with a buggy version of httping, so you may need to build it from sources to get SSL support and a few other features that seem to have fallen out.
Building from sources is easy; you'll need the OpenSSL development libraries, which on Debian are libssl-devel, and on Fedora are openssl-devel. Unpack the tarball and run:
# make all
# make install
That's all there is to it.
httping is also designed to be a Nagios plug-in. The command definition looks like this:
define command{ command_name check_httping command_line /usr/bin/httping -N 2 -c 1 -h $HOSTADDRESS$ }
man 1 httping
httping home page: http://www.vanheusden.com/httping/