Optimal settings for using Apache as a back-end server for ELB

You are here:
< Back

I want to use an instance running Apache as my backend server for Elastic Load Balancing (ELB) load balancers. What settings should I update for best performance?


For optimal performance, update the following attributes in the Apache configuration file (/etc/httpd/conf/httpd.conf in Amazon Linux) to the recommended values:

  • Timeout – 120
    Setting timeout to a higher value than the default ELB timeout (60 seconds) helps ensure that the load balancer properly closes down idle connections. If a connection is terminated by the backend server without proper notification to the load balancer, this can result in errors.
  • KeepAlive – On
    Turning on KeepAlive reduces CPU utilization and improves response time, because the load balancer will not need to establish a new TCP connection for every HTTP request.
  • KeepAliveTimeout – 120
    When the KeepAlive option is enabled, choose a longer timeout than the default ELB idle timeout (60 seconds by default).
  • MaxKeepAliveRequests – 100
    This option sets how many requests will be served by a single TCP connection on Apache when KeepAlive is set. For optimal usage of resources, set MaxKeepAliveRequests to 100 or higher.
  • AcceptFilter – AcceptFilter http none, AcceptFilter https none
    This option is enabled by default, and instructs Apache to use the TCP_DEFER_ACCEPT option for the connections. This can cause the TCP socket to be in a “half-open” state, where the load balancer believes the connection is established, but the backend instance does not have the connection established. Issues here are generally found in low-volume load balancers where connections have time to “age” prior to being used.
  • Logging – Enabling the %{X-Forwarded-For}i option causes Apache to display the ELB x-forwarded-for header in its logs for each request, which contains the IP address of the original client. The %D option adds the time taken to complete each request to the access logs:
LogFormat "%{X-Forwarded-For}i %h %l %u %t \"%r\" %>s %b %D \"%{Referer}i\" \"%{User-Agent}i\"" combined

After updating your options, restart Apache.

Did not find what you were looking for? Open a ticket with our Help Centre and we will get back to you resolve your issue.Click Here.
Was this article helpful?
How can we improve this article?
Need help?