Home > Questions > Requesting Apache2 Tuning Tips

Requesting Apache2 Tuning Tips

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?

Categories: Questions Tags:
  1. anon
    January 15th, 2008 at 16:51 | #1

    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. January 15th, 2008 at 17:00 | #2

    Have a look at Yahoo’s performance tips.

    You might want to also install the YSlow Firefox plug in… it currently gives this site an F… so there’s a lot you can do to optimize what, how, and how often things are served.

    http://developer.yahoo.com/performance/index.html#rules

  3. VE
    January 15th, 2008 at 17:03 | #3

    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

  4. January 15th, 2008 at 17:27 | #4

    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.

  5. January 15th, 2008 at 17:53 | #5

    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.

  6. seb
    January 15th, 2008 at 20:10 | #6

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

  7. Ante Karamatic
    January 16th, 2008 at 00:09 | #7

    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.

  8. jimcooncat
    January 16th, 2008 at 07:58 | #8

    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/

  9. Travis
    January 16th, 2008 at 08:54 | #9

    Dump apache, use nginx instead: http://wiki.codemongers.com/Main

  10. Carl-Christian Salvesen
    January 16th, 2008 at 09:07 | #10

    I’m handeling some 250k+ pageviews a day. The easy way out is to use the frontend-cache varnish. http://varnish.projects.linpro.no/

  11. December 17th, 2008 at 22:09 | #11

    Article about mod_deflate settings like on Amazon EC2 AMI
    http://railsgeek.com/2008/12/16/apache2-httpd-improving-performance-mod_deflate-gzip