4

The standard says:

10.5.4 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.

REF: https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html

If the server is having lock contension at the database access level, should the server return 503 in such cases. Or is the 503 status meant for:

  • Network overload
  • DOS type situations
  • Maxed out load balancing
  • Explicit maintenance window.

What other circumstances it makes sense to return HTTP status 503.

Any detailed clarification is much appreciated.

Sandip Chitale
  • 427
  • 1
  • 6
  • 9

2 Answers2

2

Let's say the service experiences a contention for the database. There are no rules as to what a server MUST do. You may however choose to return a 503 if you believe the issue is temporary and will be resolved after some time. You can specify the Retry-After header to inform the caller when he could retry. This is especially useful to allow the caller to automatically recover from the issue. You may use it for some of your other scenarios as well as the callers could automatically retry after the specified period.

The status codes serve 2 purposes

  1. Let the caller know what happened
  2. Let the caller know what he could do next

Sending the caller a 503 with Retry-After provides more options to the caller than say sending a 500. Of course the caller is free to totally ignore the Retry-After and treat it as a 500 but you as a service provider are providing more information and options.

uncaught_exception
  • 1,068
  • 6
  • 15
2

The updated spec, for reference.

If the server is having lock contension at the database access level, should the server return 503 in such cases

Keep in mind, in a REST model HTTP status codes aren't about describing the problem in your service; they instead describe an analogous condition in a document store.

503 is the way that a document store says "I'm too busy, try again later."

What other circumstances it makes sense to return HTTP status 503.

Back pressure. From Martin Thompson

Applying back pressure is one effective technique for coping with sustained high-load, such that maximum throughput can be delivered without degrading system performance for the already accepted requests and transactions.

When we need to support synchronous protocols like REST then use back pressure, signalled by our full incoming queue at the gateway, to send a meaningful “server busy” message such as the HTTP 503 status code

VoiceOfUnreason
  • 52,766
  • 5
  • 49
  • 91