So, you have built a great web-site with PHP or Java, and you have
tested it by accessing the page in your browser. It seems to pop-up
really quickly, do you think it is ready for deployment ? What if 100
people access it at the same time, or 10,000 ? What would its response
time be ? If it is too low, forget about it, no-one has time these days
to wait more than a few seconds before jumping to the next item in the
google search list.
Wget is a great tool for scripting programs that download content from the Web. I often use it as a "quick and dirty" tool for loading a web-site in order to test and monitor its performance.
There are many commercial and open-source tools available, but none are quite as simple as wget, which has a zero learning curve and probably the least amount of bugs.
Here is a simple bash script (save as "wload") that forks multiple processes that each access your site , and prints out the total time taken for all requests to complete. Note that it uses a file named pages.txt which contains a list of pages that you want each process to download (one address per line ):
if [[ $# < 1 ]]; then
echo "Usage: wload #processes(eg. 1000)"
exit
fi
start=`date +%H:%M:%S`
for ((i=1; i<=$1; i++))
do
wget -o /dev/null -q -O /dev/null -i pages.txt &
done
wait
end=`date +%H:%M:%S`
printf "%s " `hostname` $1 $start $end
echo
Note that it prints out the hostname of the loading machine, since I expect to run this script on multiple machines to further increase the loading capacity. Also, I write the files to /dev/null to remove any possible I/O overhead.
An example of a pages.txt file:
http://192.168.1.100/index.html
http://192.168.1.100/link1.html
http://192.168.1.100/img1.jpeg
http://192.168.1.100/link2.html
http://192.168.1.100/img2.jpeg
Next week, I will show how to use Expect to create a controlling program that spawns these scripts on multiple machines, and collates the results for ease of use.