How to solve AWS ELB / EC2 HTTP 503 with timeout settings?

I get intermittent but regular 503 errors ("Service Unavailable: Back-end server at capacity") from a site consisting of 2 t2.medium instances per ELB. None of them are under especially heavy load, and all observations seem normal.

AWS documents here: http://docs.aws.amazon.com/ElasticLoadBalancing/latest/DeveloperGuide/ts-elb-error-message.html let's say that the potential reason is the wrong timeout settings between ELB and EC2: "set time- keep-alive out equal to or equal to the idle timeout settings of your load balancer "

Apache conf on EC2s has:

  • Keepalive on
  • MaxKeepAliveRequests 100
  • KeepAliveTimeout 5

The wait timeout on the load balancer is 60 seconds.

It would seem that this was the reason, but I am not sure about the correction. Increasing Apache's KeepAliveTimeout is not - I understand - usually recommended, and I'm equally not sure that reducing latency on ELB will have website performance.

What is the recommended approach? How can I get an idea of ​​what ideal settings for my settings and the type of traffic (currently about 30-50 requests / min) it is dealing with?

+8
amazon-web-services amazon-ec2 amazon-elb
source share
1 answer

I would reduce the downtime in ELB. Clients need to open new connections more often, but this is slightly slower than reusing a keepalive connection.

Bringing keepalive to 60 in Apache will also fix 503, but you need to be careful not to end with connections or memory, especially with pre-selling mpm, because you will get many more slots used in keepalive. Use working mpm (or the mpm event, if you are not afraid of the warning “This MPM is experimental”), make sure that you have high enough MaxClients to handle all requests, but low enough so that it is not out of memory.

+3
source

All Articles