I want to use an instance running Apache as my back-end 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

Recommended value: 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 back-end server without proper notification to the load balancer, this can result in errors.

 

KeepAlive

Recommended value: 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

Recommended value: 120

When the KeepAlive option is enabled, choose a longer timeout than the default ELB idle timeout (60 seconds by default).

 

MaxKeepAliveRequests

Recommended value: 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

Recommended values:  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 back-end 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

Recommended values:

LogFormat "%{X-Forwarded-For}i %h %l %u %t \"%r\" %>s %b %D \"%{Referer}i\" \"%{User-Agent}i\"" combined

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.

After updating your options, restart Apache.

Apache, timeout, keepalive, logging, ELB, load balancer, back-end server


Did this page help you? Yes | No

Back to the AWS Support Knowledge Center

Need help? Visit the AWS Support Center

Published: 2016-07-19