You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modules-dev@httpd.apache.org by Joshua Marantz <jm...@google.com> on 2011/04/12 02:18:33 UTC

KeepAlive -- why is it off by default?

webpagetest.org gives a big red *F *to web sites that do* *not have
KeepAlive enabled.  Yet, at least in the CentOS installation of Apache, it
is off by default.  Why is that?  What are the reasons that KeepAlive should
be off?

Although it's trivial to turn it on in httpd.conf, many web sites do not do
it.  We are debating turning it on by default in mod_pagespeed.  This seems
counterintuitive (and maybe beyond the moral boundaries of our module) but
lots of sites on the internet appear to install mod_pagespeed but not bother
to turn KeepAlive on.  So we could either (a) engage in a campaign to get
site owners to understand what KeepAlive is or (b) turn it on by default in
mod_pagespeed and perhaps give users an option to stop mod_pagespeed from
doing so.

What are the reasons someone might wish to turn KeepAlive off?  The only one
I can think of is in single-process mode (httpd -X) it can be a drag to
refresh a page with lots of resources; but this seems like a secondary issue
that could be worked around if needed.

-Josh

Re: KeepAlive -- why is it off by default?

Posted by Joshua Marantz <jm...@google.com>.
Thanks Ben -- that's pretty compelling.  IMO the day when the general
population moves beyond pre-fork into an event-driven model cannot come soon
enough.

In fact, your observation is consistent with my experience with "httpd -X"
where the waterfall diagram in Firebug for a page refresh had approximately
7-second stairsteps -- I think 2 seconds for linger and 5 seconds for
KeepAlive.

-Josh

On Mon, Apr 11, 2011 at 9:29 PM, Ben Noordhuis <in...@bnoordhuis.nl> wrote:

> On Tue, Apr 12, 2011 at 02:18, Joshua Marantz <jm...@google.com> wrote:
> > What are the reasons someone might wish to turn KeepAlive off?  The only
> one
> > I can think of is in single-process mode (httpd -X) it can be a drag to
> > refresh a page with lots of resources; but this seems like a secondary
> issue
> > that could be worked around if needed.
>
> Lower throughput under heavy load.
>
> With KeepAlive on, each client gets allocated a process (or thread) to
> serve the requests. That process isn't doing anything useful between
> the client's requests so you end up with lots of idle processes, even
> when it's peak traffic.
>
> The event MPM is purposely written to deal with this issue: it puts
> the idle connection in a pool so the worker can serve other requests.
>

Re: KeepAlive -- why is it off by default?

Posted by Ben Noordhuis <in...@bnoordhuis.nl>.
On Tue, Apr 12, 2011 at 02:18, Joshua Marantz <jm...@google.com> wrote:
> What are the reasons someone might wish to turn KeepAlive off?  The only one
> I can think of is in single-process mode (httpd -X) it can be a drag to
> refresh a page with lots of resources; but this seems like a secondary issue
> that could be worked around if needed.

Lower throughput under heavy load.

With KeepAlive on, each client gets allocated a process (or thread) to
serve the requests. That process isn't doing anything useful between
the client's requests so you end up with lots of idle processes, even
when it's peak traffic.

The event MPM is purposely written to deal with this issue: it puts
the idle connection in a pool so the worker can serve other requests.

Re: KeepAlive -- why is it off by default?

Posted by Joe Nardone <jn...@gmail.com>.
webpagetest.org gives a big red *F *to web sites that do* *not have
> KeepAlive enabled.  Yet, at least in the CentOS installation of Apache, it
> is off by default.  Why is that?  What are the reasons that KeepAlive should
> be off?
The default in 2.2 is on for KeepAlive.

Redhat's docs (right or wrong) are fairly clear on their rationalization 
for defaulting to off:

"Note that when the persistent connections are enabled, on a busy 
server, the number of child processes can increase rapidly and 
eventually reach the maximum limit, slowing down the server 
significantly. To reduce the risk, it is recommended that you set 
|KeepAliveTimeout| to a low number, and monitor the 
|/var/log/httpd/logs/error_log| log file carefully."

This doesn't mean they are right, but they have been doing it for a 
while.  Here's a thread from back in '07 on the same topic:

http://www.redhat.com/archives/nahant-list/2007-September/msg00105.html

I guess the question should be: is Redhat's position on KeepAlives valid?

Joe