2

HTTP status code 503 is described in rfc2616 as being relevant when the server is "currently unable to handle the request due to a temporary overloading or maintenance of the server".

There are cases when an application may be down for maintenance. There are cases where an application may be over capacity.

In a server application I'm developing, I'd like to be able to differentiate between these two cases in the HTTP response such that client applications can be aware of a more precise reason for the service being unavailable.

Client applications could then display to the user either an "over capacity" or a "down for maintenance" notification to users as is relevant.

I could opt for using an undefined 5XX status code (for example 520), however I'd prefer to go with a defined standard approach if there is one.

Is there a defined standard approach for differentiating in the HTTP response between being unavailable due to capacity issues and unavailable due to maintenance?

Community
  • 1
  • 1
Jon Cram
  • 16,609
  • 24
  • 76
  • 107

3 Answers3

1

If you don't want to define your own status code, you can use 503 and set different custom error messages, according to if it is "over capacity" or "down for maintenance".

You could also set the Retry-After response header field, for example in case you know when your maintenance is done and the server is back up.

Details for the status codes:
http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html

Details for the Retry-After header field:
http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html

Terry
  • 14,529
  • 13
  • 63
  • 88
  • what about 410? 503 doesn't seem to be that much of an correct answer, as it's temporary, also represent lack of server which may affect our service rating to information collectors like google analystics. the 410 indicate that the resource was existed, but is gone now... – Hassan Faghihi Jan 03 '18 at 10:54
1

Don't use an undefined status code, unless you're willing to go to the process of registering it.

Also, you have the whole payload available to add additional information.

Finally, http://greenbytes.de/tech/webdav/rfc6585.html#status-429 might be of interest.

Julian Reschke
  • 40,156
  • 8
  • 95
  • 98
-1

I think 410 status code "Gone" can be correct answer, it indicate that the resource was existed before, but currently it's unavailable, and wont be available any more https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html

10.4.11 410 Gone

The requested resource is no longer available at the server and no forwarding address is known. This condition is expected to be considered permanent. Clients with link editing capabilities SHOULD delete references to the Request-URI after user approval. If the server does not know, or has no facility to determine, whether or not the condition is permanent, the status code 404 (Not Found) SHOULD be used instead. This response is cacheable unless indicated otherwise.

The 410 response is primarily intended to assist the task of web maintenance by notifying the recipient that the resource is intentionally unavailable and that the server owners desire that remote links to that resource be removed. Such an event is common for limited-time, promotional services and for resources belonging to individuals no longer working at the server's site. It is not necessary to mark all permanently unavailable resources as "gone" or to keep the mark for any length of time -- that is left to the discretion of the server owner.

Hassan Faghihi
  • 1,888
  • 1
  • 37
  • 55