Google Answers Logo
View Question
 
Q: Apache Directive - KeepAlive and KeepAliveTimeout ( No Answer,   3 Comments )
Question  
Subject: Apache Directive - KeepAlive and KeepAliveTimeout
Category: Computers > Software
Asked by: whizhost-ga
List Price: $150.00
Posted: 28 Mar 2003 07:22 PST
Expires: 30 Mar 2003 07:15 PST
Question ID: 182307
I run a very busy web server, my load averages are high and I'm
looking at ways to reduce the load. Reducing the load is my primary
aim, I don't care about anything else.

I have several questions about Apache's KeepAlive and KeepAliveTimeout
directive. I understand what they do but I'm not clear on the
following:

1. To reduce load on a very busy web server, would it be prudent to
disable KeepAlive? Please explain why.

2. My MaxClients is set to 200, if KeepAlive was enabled then what
KeepAlive setting would be reasonable (e.g. 1-2 sec or much longer?)
to reduce load on a very busy web server?

2. My MaxClients is set to 200, if KeepAlive was enabled then what
KeepAliveTimeout setting would be reasonable (e.g. 50-100 or much
higher?) to reduce load on a very busy web server?

Apache's manual is vague and other websites have no information for
tuning Apache's KeepAlive directive for very busy web servers. Please
help.

Thank you.

Request for Question Clarification by sldreamer-ga on 28 Mar 2003 13:03 PST
Hi whizhost,

Could you please tell me what version of Apache you are running, and
what operating system it is running on?

Thanks,
sldreamer

Clarification of Question by whizhost-ga on 28 Mar 2003 21:28 PST
I'm running Apache version 1.3.x on RH 7.1.
Answer  
There is no answer at this time.

Comments  
Subject: Re: Apache Directive - KeepAlive and KeepAliveTimeout
From: denco-ga on 28 Mar 2003 16:45 PST
 
Howdy whizhost-ga!

The Apache Software Foundation web site has:

http://perl.apache.org/docs/1.0/guide/performance.html

"If your mod_perl server's httpd.conf includes the following
directives:

KeepAlive On
...
you have a real performance penalty, since after completing
the processing for each request, the process will wait for
KeepAliveTimeout seconds before closing the connection and
will therefore not be serving other requests during this
time. With this configuration you will need many more
concurrent processes on a server with high traffic ...
...
The chances are that you don't want this feature enabled.
Set it Off with: KeepAlive Off"

They also have (about tuning a FreeBSD system):

http://httpd.apache.org/docs/misc/perf-bsd44.html

"Accept filters provide the most benefit on servers that are
already so busy that they are configured with "KeepAlive Off".
HTTP KeepAlive (aka persistent connections) avoids the cost of
setting up a new connection for every request, but connections
that are being kept alive use up one of the available child
processes. Since there is a limited number of child processes
this can significantly reduce the capacity of the server. The
viewers of a web site will still get a lot of the benefit 
persistent connections even with a very small KeepAliveTimeout
so you should try reducing it before turning it off altogether."

So, it appears that even if you aren't running mod_perl and/or
FreeBSD there are some performance gains to be made from reducing
the KeepAliveTimeout setting or by turning KeepAlive off.

There is a really good page on performance at:

http://httpd.apache.org/docs/misc/perf-tuning.html

Which includes a statement that I have found very true in
the past when I ran an ISP:

"The single biggest hardware issue affecting webserver
performance is RAM ..."

I had a pretty lame server that was turned completely around
by going from 64M to 128M of RAM.

The above page also covers:

Hardware and Operating System Issues 
Run-Time Configuration Issues 
Compile-Time Configuration Issues

Hope this Comment will help you some.  If you have any questions
or need of clarification, feel free to ask!

Looking Forward, denco

Search strategy; usedthese keyworks at: http://www.apache.org

performance keepalive
load performance
Subject: Re: Apache Directive - KeepAlive and KeepAliveTimeout
From: whizhost-ga on 28 Mar 2003 21:26 PST
 
Denco,

Thanks for your reply. I'm running Apache version 1.3.x on RH 7.1.
I've read all of Apache's manuals and I've optimized everything by the
book. I'm well aware of the other factors that you've mentioned.

The bottom line: my specific questions about KeepAlive and
KeepAliveTimeout is still NOT answered.
Subject: Re: Apache Directive - KeepAlive and KeepAliveTimeout
From: denco-ga on 29 Mar 2003 19:05 PST
 
Howdy whizhost-ga,

"1. To reduce load on a very busy web server, would it be prudent to
disable KeepAlive? Please explain why."

Yes, disabling KeepAlive would reduce load; as per the Apache
Software Foundation page at:

http://perl.apache.org/docs/1.0/guide/performance.html#KeepAlive

"... since after completing the processing for each request, the
process will wait for KeepAliveTimeout seconds before closing the
connection and will therefore not be serving other requests during
this time. With this configuration you will need many more concurrent
processes on a server with high traffic."


"2. My MaxClients is set to 200, if KeepAlive was enabled then what
KeepAlive setting would be reasonable (e.g. 1-2 sec or much longer?)
to reduce load on a very busy web server?"

For this question, I think you might be asking about the settings
(in seconds) of KeepAliveTimeout; as per:

http://httpd.apache.org/docs/mod/core.html#keepalivetimeout

"Setting KeepAliveTimeout to a high value may cause performance
problems in heavily loaded servers. The higher the timeout, the
more server processes will be kept occupied waiting on connections
with idle clients."

The lower the KeepAliveTimeout setting, the less load there will be,
so if you are not disabling the KeepAlive directive, then as they
state at:

http://httpd.apache.org/docs/misc/perf-bsd44.html

" ... viewers of a web site will still get a lot of the benefit of
persistent connections even with a very small KeepAliveTimeout so
you should try reducing it before turning it off altogether."

Since the default setting for KeepAliveTimeout is 15, then a "very
small" setting of 2 seconds, then 1 second would be appropriate to
see if there is a difference in the load.


"2. My MaxClients is set to 200, if KeepAlive was enabled then what
KeepAliveTimeout setting would be reasonable (e.g. 50-100 or much
higher?) to reduce load on a very busy web server?"

As you are referring to a setting of 50-100, I think you might
actually be talking about the MaxKeepAliveRequests directive:

http://httpd.apache.org/docs/mod/core.html#maxkeepaliverequests

The MaxKeepAliveRequests directive limits the number of requests
allowed per connection when KeepAlive is on. If it is set to "0",
unlimited requests will be allowed. We recommend that this setting
be kept to a high value for maximum server performance."

Default for MaxKeepAliveRequest is 100, so I would suggest setting
it to that while testing the other settings.


Since you have "optimized everything by the book" then tuning the
KeepAlive settings is not really going to buy you that much time,
before load becomes an issue once again, or there starts being
user issues.

If this is a server with multiple domains on it, then it might be
time to offload some of those sites to a different server.

If it is a single domain/site server, then it might be time for a
faster/bigger/better server.

denco

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy