|
Page Speed and Webserver Performance
May 22, 2004
At the very bottom of this webpage, you'll see a like that states:
"This page was generated in X.XX seconds." This is measured
by a little snippet of timing code that we've put into the PHP which
generates the pages on our website. Hopefully it's a very small
number.
Optimizing your webserver performance is important for high
traffic, successful websites. In extreme cases, the user experience
is dependant on getting good response from the webserver. Having the
webserver take 15 seconds to generate the webpage is generally viewed
poorly. On the other end of the spectrum, few users care about the
difference between a page genearted in 0.05 seconds and one generated
in 0.01 seconds. The Internet lag and their modem/broandband download
times are usually much greater than 4 hundredths of a second.
However the difference between 0.05 seconds and 0.01 seconds is
also the difference between the webserver processing 20 requests/sec
and processing 100 requests/sec. This is much more important to the
webmaster/owner of the website. Greater server capacity means that
your website can become more successful before having to spend money
on faster/more complex hardware.
Optimization Techniques
There are entire books devoted to speed optimization or
"tuning" of computer hardware and software, so I really
can't into great detail in this one small article, but when you boil
it down, most of the easily implemented options are these:
- Add more RAM - Very often this is the quickest and cheapest
method of getting more performance out of your webserver. Consider
that 256Mb of RAM now costs less than the server charge most places
will sock you for installing it, RAM is pretty cheap, don't skimp on
it. As of this writing, I've got 1Gb of RAM on this server.
RAM is used for two things by your webserver. First and foremost
it's used for the programs short-term memory needs. On some systems,
any RAM that's left over is used as a disk cache, to store frequently
used files from the hard drive. (Linux systems dynamically allocate
spare RAM to the disk cache, BSDi systems require the admin to
determine how much RAM is used as disk cache when the kernel is
compiled. Win2k servers use whatever RAM is left over to act as disk
cache.)
- Index your database tables - Entire chapters of database
books are devoted to this subject as the "right" answer
varies depending on your situation and how your database tables are
used. In general, adding indexes to the table makes database searches
faster and database writes slower. Since most data is read many times
and written once, it's more efficient to optimize the read operation.
- Buy a faster server - This suggestion is kind of
self-defeating as Justin and I make our living programming, but
sometimes it's cheaper and faster to throw newer hardware at the
problem. A new low end server can cost as little as $600, which will
probably double your server performance, assuming you're replacing a
server that's 2-3 years old.
Professional help (like us) can sometimes achive much greater
performance gains, but if doubling is all you need, then new hardware
might be your cheapest solution.
- Code tweaks - Rewriting the code to be more efficient can
greatly improve your webserver performance. However this is best left
to the pros and will often cost a signifigant portion of the original
development costs.
Rene
If you have any comments or questions, please feel free to drop Rene an
email at [email protected]. If
you would like assistance in setting up this kind of feature on your website,
please contact us for a quote.
|
|