title: How to solve AWS ELB/EC2 HTTP 503 with timeout settings?
body: <p>I'm getting intermittent but regular 503 errors ("Service Unavailable: Back-end server is at capacity") from a site consisting of 2 t2.medium instances behind an ELB. None are under particularly heavy load and all monitoring seems normal.</p>
  
  <p>The AWS docs here:
  <a href="http://docs.aws.amazon.com/ElasticLoadBalancing/latest/DeveloperGuide/ts-elb-error-message.html">http://docs.aws.amazon.com/ElasticLoadBalancing/latest/DeveloperGuide/ts-elb-error-message.html</a>
  say that a potential cause is mismatched timeout settings between the ELB and EC2s: "set the keep-alive timeout to greater than or equal to the idle timeout settings of your load balancer"</p>
  
  <p>Apache conf on the EC2s has:</p>
  
  <ul>
  <li>KeepAlive On</li>
  <li>MaxKeepAliveRequests 100</li>
  <li>KeepAliveTimeout 5</li>
  </ul>
  
  <p>Idle timeout on the load balancer is 60 seconds.</p>
  
  <p>This would seem, then, to be a cause, but I'm unsure about the fix. Increasing the Apache KeepAliveTimeout isn't - I understand - normally recommended, and I'm equally unsure about the effect that reducing the idle timeout on the ELB will have on site performance.</p>
  
  <p>What's the recommended approach? How can I get an idea of what the ideal settings are for my setup and the sort of traffic level (currently about 30-50 requests/min) it deals with?</p>