Saturday, March 24, 2007

Web Site Response Time

I was asked to monitor the response time of one of our managed hosting customers' site. The reason for doing it is to cover somebody's backside in case they were asked "why the site is so slow one ha?" (in Singlish). I can tell you that I hate to do this type of thing, but what can I do....

Anyway, I used one of the Solaris zones and compiled Tcl with tDOM, and httperf. These are the steps that I used:

  1. Download the home page html using Tcl with http package
  2. Parse the html and convert that to a DOM tree with tDOM
  3. Retrieve all the dependencies (image, flash, javascript, css, ...)
  4. Write a temporary file of the html + dependencies, this will be used as the httperf's session workload input file (see -wsesslog option)
  5. Execute httperf with 2 concurrent connections (that's normally configured in web browsers)
  6. Append the data in RRD update format
  7. RRD update format will be cut and paste to my auto graph generator S.T.A.R.

Here is the output graph

The home page consists of 17 thumbnail photos (in jpg format) and other stuff. However, these jpeg files are of size of 225x141 and they are all forced to display in 125x71. If we were to convert these thumbnail photos to the correct size (125x71), we could have saved 364,107 bytes. According to my calculation, the response time of the home page will be reduced by a maximum of 0.93 seconds on a 1.5Mbps internet connection.

The above was put forward to the developer, but I was told the 225x141 size photos were being used in another location. Instead of creating another set of thumbnails for the home page, the thumbnails were forced to display smaller (125x71). Of course it works by wasting a lot of bandwidth and making the home page load slower.

The developer may not know that this can be easily done in Solaris. FYI, ImageMagick is now a built-in utility in Solaris. It is located under the /usr/sfw directory and the package name is SUNWimagick. A script like this can create another set of thumbnails of size 125x71.

PATH=/usr/sfw/bin:$PATH; export PATH
for i in *jpg
new="`basename $i .jpg`_s.jpg"
convert $i -resize 125x71 $new
It took 5 seconds on my X4500 to create another set of thumbnails for the home page. With a one time effort of 5 seconds CPU time, you are likely to reduce the home page response time by almost 1 second. The choice is yours. From the above graph, you can see the response time reduced by almost a seconds after 22 March. FYI, the above was proposed to the developer on the 15 March.

Labels: , , , , ,


Post a Comment

<< Home