1

I would like to know if an error 504 Gateway timeout always come from the load balancer or it can also be originated from Apache and the PHP code it's running ?

Thanks

mnml
  • 337
  • 1
  • 7
  • 21

3 Answers3

3

It usually happens when the load balancer is waiting for a response from apache and apache is not giving a response within the timeout period of load balancer. So it returns a 504 gateway timeout. About what causes apache to not respond is something only you can say as you have not given much background information on what apache is serving. Look at apache logs to know more details . usually access logs and error logs. Increase the timeout value of loadbalancer, to see if it helps. It is always good to have clustering on apache so you dont get 504 because of a dead apache instance. I think mod_proxy allows you to achieve software clustering. I am not sure check out on apache site.

bagavadhar
  • 538
  • 4
  • 14
2

Usually from balancing because Apache(mod_php) or PHP(FastCGI) down or busy.

ooshro
  • 11,134
  • 1
  • 32
  • 31
1

Sure it can be from php. If php script is in some loop and wont 'spit' out the content connection will eventually time out and balancer will report gateway timeout.

That 'loop' does not necessarily need to be loop, it can be waiting on connection to some service to read data from like mysql/memcache or something...

Hrvoje Špoljar
  • 5,245
  • 26
  • 42
  • You're wrong. PHP it's not web-server and can't send any HTTP response. – ooshro Feb 24 '11 at 14:54
  • 1
    Not entirely true, @ooshro, PHP can set headers with header().. but I'm not entirely sure that's appropriate in this instance. – Tom O'Connor Feb 24 '11 at 15:00
  • @Tom You're wrong. PHP need use socket to send any network message. header() need mod_php, CGI or FastCGI. – ooshro Feb 24 '11 at 15:05
  • 1
    The OP says " from Apache and the PHP code it's running" Assuming some kind of mechanism between apache and PHP. One that is capable of handling header() – Tom O'Connor Feb 24 '11 at 15:10