Reputation: 1263
As per https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/using-features.healthstatus.html the web service should respond with 200 OK
HTTP status code to signal a healthy application or any other one for unhealthy.
My questions is which HTTP status is most appropriate for an unhealthy application?
Out of all HTTP status classes below
1xx Informational response
2xx Success
3xx Redirection
4xx Client errors
5xx Server errors
simple logic suggests it should be a server error other than anything else and out of all the 5xx Server errors
codes 503 Service Unavailable
fits most naturally however I couldn't find any documentation supporting this.
Upvotes: 0
Views: 169
Reputation: 57299
My questions is which HTTP status is most appropriate for an unhealthy application?
503 Service Unavailable, or a lower level TCP RST, are perfectly satisfactory ways for a service to announce that it isn't currently available. You can use Retry-After if you want to suggest a time to wait. I haven't seen any documentation suggesting that the ELB client will respect that header.
GCP and Azure are similar; 200 Healthy, anything else is not. The Azure document suggests a 500 Internal Server Error as one possible candidate, which is of course fine (Y00 is the coarse grained approximation of all Yxx codes).
The protocol for Consul checks is similar -- 2xx for healthy, 429 Too Many Requests for a warning (which is a really odd choice), and anything else for failure.
I'm not a big fan of using a Client Error to describe what is a server problem; but I don't know that it really hurts anything. The semantics of Retry-After
is really only clearly defined for 3xx and 429/503, so if you are hoping to leverage that you should restrict yourself to those codes.
Otherwise, you could dig through the status code registry to see if there is a code you think is more suitable.
Upvotes: 1