View Full Version : Measure Response Time
OOagent137
2003-08-18, 02:11 AM
Ok, I'm trying to develop methods to monitor our server.
I was thinking (somebody suggested this in an earlier forum post) that I could make a script that measures the response time every x number of minutes and broke down that statistic in a hourly, daily, weekly, and monthly format.
1) How would I measure response time? Would I just try and download a file from a domain on the server? What domain do I choose? Does it matter?
2) Basically, once I figure out a method to measure response time, how do I even begin to write a script that calcualtes this? I don't need anything to show up in a graph (though that would be nice), text based will do.
3) Any other thoughts, suggestions, experiences?
tylerl
2003-08-27, 19:11 PM
First of all, you have to decide what you want. That's not a question we can answer for you. "Response time" is kind of a vague idea-- it's like asking for a way of measuring how "good" a computer is.
One possibility is to measure ping times. That would have nothing to do with your server, of course. It would simply be the speed of the network between the two (the server you're testing and the client you're testing it with). You could also measure the time it takes to download a file.
Finally, to run all your calculations, I'd suggest some sort of perl script. If you don't know perl then... well... I guess you have to start somewhere.
Here are a few ideas. These, of course, go in separate files that you make executable and run.
---------------------------- << Ping time
#! /usr/bin/perl
$str = `ping www.google.com -c 1`;
($time) = $str =~ /time=(.+)$/m;
print "$time\n";
------------------------------ << Amount of time to download webpage
#! /usr/bin/perl
$time = `/usr/bin/time 2>&1 -f "%e" GET http://www.google.com/ >/dev/null`;
print "$time seconds\n";
--------------------------------
You should learn how these scripts work and modify them to do what you want.
The best way to measure web response time would be to create a 0 byte file and try to download it from a remote location. Ping is a rather poor method to measure response since ICMP is commonly filtered and is considered low priority. The file should be located where it can be downloaded by using the IP address of your server .. if you use a hostname for one of your virtual hosts, there will be a delay for DNS resolution and may skew your results. You can upload an empty file or run "touch testfile.txt" through the shell to create an empty file.
Here is a sample Perl script you could run on the remote system. It uses the Time::HiRes module and the LWP::Simple module. If you're going to use Perl, might as well go all the way :)
#!/usr/bin/perl -w
use strict;
use LWP::Simple;
use Time::HiRes qw( gettimeofday );
my $start = gettimeofday();
get("http://192.168.123.1/testfile.txt");
my $end = gettimeofday();
my $delta = ($end - $start);
print localtime().",$start,$end,$delta\n";
exit 0;
You would of course replace 192.168.123.1 with the IP address of your server. The output would be in CSV format which you can import into a spreadsheet or write a script to make further calculations with. If you plan on reading this on a Windows machine, change that lonely "\n" to "\r\n". :)
There are some 3rd party monitoring solutions such as NetWhistle which can do a lot of this for you, and even have a handy little interface to manage it. Some of them are free for 1-5 domains, but anything over that and they hit your wallet hard. :)
awsolutions
2003-08-28, 01:27 AM
QT,
Why not just use the local loopback (127.0.0.1) instead of having people replace the ip address?
Wouldn't that work too? Or is this so you can test network connectivity?
This is to measure the response time over the network. The script should be run on a remote system (i.e. not on the server you are testing). How many of your customers will be connecting from localhost? ;)
awsolutions
2003-08-28, 09:34 AM
Thats what I thought after suggesting it.
OOagent137
2003-08-28, 22:38 PM
Thanks for the suggestions. I'm not really ready to make the time committment to Perl yet, so I guess we'll have to go with a premade script. Thanks for the suggestions and help, I may just refer back to this post later when I'm prepared to learn Perl.
vBulletin® v3.6.8, Copyright ©2000-2008, Jelsoft Enterprises Ltd.