Search code examples
amazon-web-servicesapacheload-balancingamazon-elb

Apache2 Event MPM behind Loadbalancer


I am currently configuring some web servers running Apache2 and a PHP based web app. The servers are running the same PHP codebase on the same system configuration and should be placed behind a load balancer on AWS. The LB accepts and terminates HTTPS connections, and forwards them as HTTP traffic to the web servers, so in theory the Event MPM should work and make sense.

Now, since the servers are sitting behind an LB, my question is: Are the connections between the LB and the web servers being kept alive ("keepalive") in this scenario? Also, do the TLS-connections result in the event-mpm to behave like a worker-mpm or not, even if the HTTPS-connections are terminated by the LB and forwarded as unencrypted HTTP traffic?

Ref: https://serverfault.com/questions/383526/how-do-i-select-which-apache-mpm-to-use?answertab=votes#tab-top


Solution

  • With help of the AWS support, I was able to find an answer to the question:

    The AWS LB opens an unlimited number of connections to the servers behind it, so the Apache settings have to be configured in a way such that the number of worker threads optimally uses the underlying system's resources. If you see that neither your servers' memory nor CPU load comes anywhere near its capacity (even during a stress test), then you might want to increase the number of worker threads/processes in the Apache config.

    Also: If the LB terminates HTTPS connections and forwards them as HTTP traffic, the Event MPM will work as intended, which is apparently also the most optimal MPM for Apache when using an AWS LB, unless you use HTTPS between the LB and the servers. In that case, the worker MPM will do just fine.