Apache

 < Day Day Up > 

Despite being the most popular web server on the Internet, Apache is by no means the fastest. Part of the "problem" is that Apache has been written to follow every applicable standard to the letter, so much of its development work has been geared toward standards-compliancy rather than just serving web pages quickly. That said, with a little tweaking we can convert a $1,000 Dell server into something capable of surviving the Slashdot Effect.

NOTE

Slashdot.org is a popular geek news website that spawned the Slashdot Effect the result of thousands of geeks descending on an unsuspecting website simultaneously. Our $1,000 Dell server had dual-2.8GHz Xeons with 1GB of RAM and SCSI hard disks if you have more RAM, faster chips, and a high-end network card you can kick sand in Slashdot's face.


The first target for your tuning should be the httpd.conf file in /etc/httpd/conf, as well as the other files in /etc/httpd/conf.d. The more modules you have loaded, the more load Apache is placing on your server take a look through the LoadModule list and comment out (start the line with a #) the ones you do not want. Some of these modules can be uninstalled entirely through the Add or Remove Packages dialog.

As a rough guide, you will almost certainly need mod_mime and mod_dir, and probably also mod_log_config. The default Apache configuration in Fedora is quite generic, so unless you are willing to sacrifice some functionality you may also need mod_negotiation (a speed killer if there ever was one), and mod_access (a notorious problem). Both of those last two modules can and should work with little or no performance decrease, but all too often they get abused and just slow things down.

Whatever you do, when you are disabling modules you should ensure you leave either mod_deflate or mod_gzip enabled, depending on your Apache version. Your bottleneck is almost certainly going to be your bandwidth rather than your processing power, and having one of these two compressing your content will usually turn 10Kb of HTML into 3Kb for supported browsers (most of them).

Next, ensure keepalives are turned off. Yes, you read that right: turn keepalives off. This adds some latency to people viewing your site, because they cannot download multiple files through the same connection. However, in turn it reduces the number of simultaneous open connections and so allows more people to connect.

If you are serving content that does not change, you can take the extreme step of enabling MMAP support. This allows Apache to serve pages directly from RAM without bothering to check whether they have changed, which works wonders for your performance. However, the downside is that when you do change your pages you need to restart Apache. Look for the EnableMMAP directive it is probably commented out and set to off, so you will need to remove the comment and set it to on.

Finally, you should do all you can to ensure that your content is static: avoid PHP if you can, avoid databases if you can, and so on. If you know you are going to get hit by a rush of visitors, use plain HTML so that Apache is limited only by your bandwidth for how fast it can serve pages.

TIP

Some people, when questioned about optimizing Apache, will recommend you tweak the HARD_SERVER_LIMIT in the Apache source code and recompile. While we agree that compiling your own Apache source code is a great way to get a measurable speed boost if you know what you are doing, you should only ever need to change this directive if you are hosting a huge site.

The default value, 256, is enough to handle the Slashdot effect, and if you can handle that then you can handle most things.


     < Day Day Up > 


    Red Hat Fedora 4 Unleashed
    Red Hat Fedora 4 Unleashed
    ISBN: 0672327929
    EAN: 2147483647
    Year: 2006
    Pages: 361

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net