I am using the mix Spring-Cloud + feign + spring-retry to help retry requests on the client side (all are Kotlin-based back-ends)
My spring-boot conf is like this:
myApp:
ribbon:
OkToRetryOnAllOperations: true
retryableStatusCodes: 404, 503
(note: OkToRetryOnAllOperations=true is only present to retry also POST/PUT requests)
Retrying 404 & 503 HTTP codes sounds good, but I cannot figure out if there is a "classic" or "default" list of error codes to retry. Does this kind of good practice exist?
We suppose all the requests are idempotent on the server side (if not, retrying could cause problems).
As a very rough rule of thumb:
4XX - client did something bad
5XX - server did something bad
But it very much depends of the actual API.
Should you retry 500? Maybe, because the server had an unexpected hiccup while connecting to DB. Or, maybe you're sending it something it's not expecting, and instead of returning you 4XX it crashes.
There is usually not much reason to retry 404, unless you expect that this resource will appear.
The only HTTP codes which is valid for retry are 408, 502, 503 and 504
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With