Our infrastructure consists of load balancers running HAProxy and Apache, which forward traffic to our app servers running just Apache. The past few days, we've been seeing connection floods which the load balancers happily pass along, but the connections quickly overwhelm our application servers. They become unresponsive, and our only mitigation tactic is to launch more application servers to sustain the flood. At first we couldn't identify why these servers would go down because there were no real spikes traffic on the load balancers, but after some investigation we see that the number of Apache connections is through the roof.
Attached are some graphs which seem to be the only indicators of the flood. I've lowered the HAProxy
maxconn directive for each backend server to a more reasonable number (its previous default was 255), but I worry that new legitimate connections will be delayed until the flood subsides. The service will appear to be up for users with existing connections, but it will appear down to new connections and external monitoring services because HAProxy is rate-limiting without regard to host.
Is there anything else we can do on our end (HAProxy or Apache) to help us sustain the load, or should we look at filtering it outside our network? Since it's such a small bit of traffic, I feel like there is something more we can be doing, but I don't have much familiarity with all of the capabilities of HAProxy. I'm also interested in exploring if HAProxy can rate-limit based on IP, but I haven't found anything.
EDIT: We audited the access log for one of the load balancers, and the request counts for the top IPs are as follows:
1070 69.64.*.* 1227 1.9.*.* 1235 64.71.*.* 1376 69.64.*.* 1459 12.189.*.* 1572 1.9.*.* 1678 208.106.*.* 1982 5.15.*.* 2630 23.22.*.* 3300 76.125.*.* (our office) 3543 216.38.*.*
So, we could dynamically ban IPs that establish too many sessions within a small window, but we couldn't block based on total requests as that would catch us as well. Does this route make sense? Should we do this at the iptables level on the load balancers?
Any advice is much appreciated!