HTTP/1.1
Optimizing HTTP Server Performance 4-13
This is a 20% reduction in service time. When the system is under load, the benefit
of reducing connection time with persistent connections is even greater, due to the
corresponding reduction of the TCP queue.
Reduction in Server Workload
Another benefit of persistent connections is reduction of the work load on the
server. Because the server need not repeat the work to set up the connection with a
client, it is free to perform other work. For a very inexpensive servlet (Hello World),
the CPU ms per request was reduced by approximately 10% when the same client
made 4 requests per connection. (The impact would be far less significant for a
realistic servlet application that does more work.)
httpd Process Availability
There are some serious drawbacks to using persistent connections with Apache. In
particular, because httpd processes are single threaded, one client can keep a
process tied up for a significant period of time (the amount of time depends on your
KeepAlive settings). If you have a large user population, and you set your
KeepAlive limits too high, clients could be turned away because of insufficient
httpd deamons.
The default settings for the KeepAlive directives are:
KeepAlive on
MaxKeepAliveRequests 100
KeepAliveTimeOut 15
These settings allow enough requests per connection and time between requests to
reap the benefits of the persistent connections, while minimizing the drawbacks.
You should consider the size and behavior of your own user population in setting
these values on your system. For example, if you have a large user population and
the users make small infrequent requests, you may want to reduce the above
settings, or even set KeepAlive to off. If you have a small population of users that
return to your site frequently, you may want to increase the settings.
FIN_WAIT_2
There is a known problem with some browsers which will leave the server with a
TCP connection in the FIN_WAIT_2 state. If too many connections are left in this
state, the system will run out of the memory allocated for storing TCP connections,
and stop.