
162
|
Chapter 7: Load-Balanced Clusters
Scaling Without LB and HA
If you offered a wonderful service, would your server survive a Slashdotting (i.e., a
huge activity spike)? If not, your credibility could suffer and many visitors might
never return. But because implementing LB and HA requires significant effort and
hardware investments, it’s worth considering other solutions. There are ways to get
more from your present server. For instance, you can disable .htaccess files in your
Apache configuration (
AllowOverride None), and use mod_expires to avoid stat calls
for infrequently changed files such as images. Apache books and web sites contain
many such optimization tips.
Once you reach the limits of your web server software, consider alternatives. In many
cases, web servers such as lighttpd (http://www.lighttpd.net), Zeus (http://www.
zeustech.net), and litespeed (http://litespeedtech.com) are faster than Apache and use
less memory.
You can also get huge boosts from caching. Code caches, which include PHP acceler-
ators such as e-accelerator (http://eaccelerator.net) and APC (http://apc.
communityconnect.com), save PHP bytecode and avoid parsing overhead on each
page access. Data caches such as MySQL’s query cache save the results of identical
queries. Replication is a form of LB. memcached (http://danga.com/memcached)isa
fast way to cache data such as database lookup results. Squid (http://www.squid- ...