Requesting Apache2 Tuning Tips

By | 2008/01/15

In a continued effort to keep this site online all the time I’m looking for some help in tuning apache2.  Earlier today we ran into some serious performance issues based on what I had it tuned to, which caused 3/4 of the total swap to be used.  NOT a good idea.

In the meantime I have turned things down a bit in the prefork MPM section, but I’m wondering what other tips the community has.  What values do you suggest in prefork MPM for performance tuning?

The box is a quad-core xen vps with 512M.  I have 5,000+ unique visitors a day on this site in addition to the dozen other blogs hosted (none near as popular).  What can I do to keep up with the traffic, yet keep the load down on the machine for performance?

11 thoughts on “Requesting Apache2 Tuning Tips

  1. anon

    Might I suggest lighttp w/fcgi php. I am using it on a site that has several hundred thousand visitors a day and it works a treat.

  2. VE

    1. If your VPS uses cpanel or plesk or any of that sillyness, ditch it. It’s using a huge chunk of your ram.

    2. Make sure you need all the apache modules you have loaded.

    3. Make sure you need all the php modules you have loaded.

    4. Use a php cache

    Here’s what I’m using for a 256 meg VZ VPS running debian etch

    Timeout 200
    KeepAlive On
    maxKeepAliveRequests 100
    KeepAliveTimeout 3
    MinSpareServers 10
    MaxSpareServers 20
    StartServers 15
    MaxClients 250
    MaxRequestsPerChild 0
    HostnameLookups Off

  3. Jeff Schroeder

    Look at your bottlenecks. Are you sure it is just apache? Maybe it is wordpress or the mysql database it writes to. you can get a HUGE win by installing wp-cache. WordPress is a beast as far as resources go when you get many concurrent visitors.

    Do you have sar set up? May I suggest you take a look at atop? It helps you visualize things from interrupts to context switches to disk IO all at the same time. atop is like a better top + vmstat + mpstat + a few more.

    wp-cache is a huge win if you aren’t using it already though.

  4. Rudd-O

    ONLY five thousand visitors and the machine is bogging down? May I suggest my tutorial on improving WordPress performance? (concepts there are applicable to any PHP app running on Apache).

    It helped me survive a combined two-day slashdotting/diggdown/reddit/delicious onslaught. On 512 MB RAM.

  5. seb

    > Rudd-O,
    from a visitors point of view I liked your story v much.

  6. Ante Karamatic

    Give up on prefork MPM and use worker with fcgid. That will help a lot with RAM issues. But be sure to check that apache is taking all the RAM.

  7. jimcooncat

    If you think maybe it’s your media or image files, you could serve the media files with thttpd. This gives you the opportunity to throttle them down and save your bandwidth for the wordpress stuff.

    Of course, you’d have to change all the URLs to your media (oh gawd) and set up redirectors in Apache for those folks that linked to them directly from outside.
    http://www.acme.com/software/thttpd/

Comments are closed.