by Hydraulix989 · 9y ago · 0 comments
Do the Internet a favor, and file an issue with your favorite HTTP library asking them to implement exponential backoff.
I haven't found anything in JS that does this properly though. Do people really just write apps that crap out upon the first HTTP request failure?
The best library I have come across is actually SquareUp's OkHttp (the payment processing companies seem to be the only ones getting this right).
- Should they be the default?
- What requests should be retried? (as much as we wish GETs were idempotent... they're not) see https://lists.w3.org/Archives/Public/ietf-http-wg/2017JanMar... for an intro to the complexities here
- What should get reused? (e.g. do new dns lookup? reuse connection? reuse proxy connection?)
- How to handle non-replayable pieces? (e.g. request bodys coming from a fifo)
- Usually a request has a timeout/deadline. should it be restarted for the retry? (probably not)
I haven't implemented retries yet, as the above questions seem hard to answer without knowing application/server specific qualities (and hence should be left to the user of the http library). Please feel free to file an issue :)
As a library user I need to work around the peculiarities of the particular service endpoints I'm integrating with. Backoff and retry aren't specific to the application/transport protocol through which a service is consumed.
For example, (in the java world) the approach in libraries like hysterix, guava-retrying, and failsafe https://github.com/jhalterman/failsafe#retries
Most of the colleagues I've had have rolled their own one off solutions when needed.