Skip to content
Home » Apache KeepAlive – On or Off?

Apache KeepAlive – On or Off?

KeepAlive:
KeepAlive is to reuse the same connection to transfer multiple files between the web browser and the web server. Its a persistant connection.

 

keep-alive-enabled

KeepAlive [Advantage]:

  • Improves website speed: It reduces latency associated with HTTP transfers and delivers a better user experience.
  • Reduces CPU usage: It reduces CPU usage. If KeepAlive is disabled then separate connection gets created for each images, stylesheets, javascript files etc for a web page and it will increase CPU usage.

Keepalive [Disadvantage]:

  • Increases memory usage: Apache processes has to keep connections open waiting for new requests from established connections, thus occupying RAM and increases memory usage on the server.

KeepAlive [On or Off]: Its depends on many factors like

  • Server resources:
    Should be turned Off
    if RAM size is less/limited because having Apache processes waiting for more requests from persistent connections will be a waste of memory.
    Should be turned On if CPU power is limited because it reduces CPU load.
  • Types of sites:
    Should be turned On if Web page having a lot of images or other files linked to it because a single connection will be used to transfer multiple files and will improve the user experience significantly.
  • Traffic patterns:
    Should be turned On
    if web traffic is spread out evenly throughout a day.
    Should be turned off if Site has bursty traffic where a lot of concurrent users access during a short time period else will cause RAM usage to skyrocket.
  • Server under Load Balancer:
    Should be turned On
    if servers are under load balancer because for each request that a client makes through a load balancer, the load balancer maintains two connections and keeping KeepAlive On enables the load balancer to re-use connections to the back-end instances, which reduces the CPU utilisation.

So there is no one universal solution to tuning Apache. It all depends on the resources and the type of sites you have.

References:
https://abdussamad.com/archives/169-Apache-optimization:-KeepAlive-On-or-Off.html
http://docs.aws.amazon.com/ElasticLoadBalancing/latest/DeveloperGuide/config-idle-timeout.html
http://docs.aws.amazon.com/ElasticLoadBalancing/latest/DeveloperGuide/config-idle-timeout.html
http://users.cis.fiu.edu/~downeyt/cgs4854/timeout
https://varvy.com/pagespeed/keep-alive.html

Leave a Reply

Your email address will not be published. Required fields are marked *

0 Shares
Tweet
Pin
Share
Share
Share