Updates from the Still - apache2.conf



Written By : Josh Nichols


March 01, 2010

At Rails Machine, we have recently seen problems on a few deploys where Apache’s workers become overwhelmed and unable to serve new requests, even static ones. While we haven’t identified the root cause yet, we suspect either a recent update to The Browser Which Shall Remain Unnamed causes it to abuse the length of time connections stay alive or there may be something lurking in the recent 2.2.10 Passenger release.

Don’t worry though, because I have updates from the still about Moonshine’s Apache management. Previously, moonshine did not need to change anything in /etc/apache2/apache2.conf, so it defaulted to Ubuntu’s apache-common package… until now.

The primary motivation for doing this was specifically to turn off KeepAlive by default.

If you want to turn KeepAlive BACK on, you need to add something like this to your moonshine.yml:

:apache:
  :keep_alive: 'On'

Note that On needs to be quoted or YAML will convert it to true or false value, which would not be valid for the configuration. As a side note, I should probably find a fix for that.

If you are running a high-traffic site, and still experience problems not having idle Apache workers with KeepAlive Off, you may get some mileage out of tweaking :max_clients and :server_limits too.

To take advantage of these changes, you just need to update moonshine:

# if managed with script/plugin
script/plugin install 
# if installed using a submodule
git submodule update

For reference, here’s the commit:

commit 3f46140641fb22ce25e0b2b81497d4aec88e90b2
Author: Joshua Nichols <[email protected]>
Date:   Fri Feb 26 13:49:20 2010 -0500
 
    Added management of /etc/apache2/apache2.conf
 
    You can now specify the following apache directives using configuration:
 
     * Timeout => :timeout (default 300)
     * KeepAlive => :keep_alive (default 'Off')
     * MaxKeepAliveRequests => :max_keep_alive_requests (default 100)
     * MaxKeepAliveTimeout => :keep_alive_timeout (default 15)
     * MaxClients => :max_clients (default 150)
     * ServerLimit => :server_limit (default 16)
     * Timeout => :timeout (default 300)