lighttpd forum lighty > (mod_proxy_core) Error 503 or 504 on all backends failure?

Posted by Marek Pułczyński (Guest)
on 06.02.2007 19:09
Which would be better error code when all backends fail?

In my opinion 503 "Service Unavailable" would be better than 504 "GW 
Timeout", because it gives distinction between 504 and 503 reasons.

Besides it gives more concrete information on cause of the failure.

Unavailability is good reason to front-loadbalancer (eg haproxy), to
redispatch the request, while 504 suggests timeout of THIS request, 
which returns in sending error to a client.

?

Marek Pułczyński



According to lighttpd wiki :

In case a request to the backend fails (connections refused, connection 
timeout, ...) the request is sent to another backend. If no backend is a 
available, ``504 Gateway Timeout`` is returned.

( http://trac.lighttpd.net/trac/wiki/Docs%3AModProxyCore )

Description of 503 and 504 according to w3c

503 Service Unavailable

The server is *currently* unable to handle the request due to a 
*temporary* overloading or maintenance of the server. The implication is 
that this is a temporary condition which will be alleviated after some 
delay. If known, the length of the delay MAY be indicated in a 
Retry-After header. If no Retry-After is given, the client SHOULD handle 
the response as it would for a 500 response.

      Note: The existence of the 503 status code does not imply that a
      server must use it when becoming overloaded. Some servers may wish
      to simply refuse the connection.

504 Gateway Timeout

The server, while acting as a gateway or proxy, did not receive a timely 
response from the upstream server specified by the URI (e.g. HTTP, FTP, 
LDAP) or some other auxiliary server (e.g. DNS) it needed to access in 
attempting to complete the request.

      Note: Note to implementors: some deployed proxies are known to
      return 400 or 500 when DNS lookups time out.

( http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.5.4 )
Posted by Jay Rabbit
on 06.02.2007 20:49
Makes sense to me. If there is no proxy available to send the request to 
because they are all busy, return a 503. If you send it to a proxy and 
it doesn't respond within the require time period or dies midway through 
that request, return a 504.