It is a technique where an application progressively increases the waiting time between retry attempts after a failed operation
TL;DR
- Transient Failures do happen, for which we can retry with a limit
- Retry increases load on already overloaded servers
- Retry by adding a delay that increases exponentially, will reduce the load.
Sample Scenario
- You have an UI, which shows some data.
- The data is fetched at client side via some API
- The server serving the request is overloaded or some throttling is implemented, hence the server is rejecting new calls.
- Making the api call again may succeed.
- So this application needs to add retries.
Strategy 1 - Retry ASAP
- We want the users to see the data ASAP
- So we will retry ASAP
Problem with Immidiate Retry
- The server on load will increase drastically, You would be calling this
1000/response-time-in-ms
- Eg: For an API with response time of 50ms, it would now make 20 calls per second.
- So we should probably add some waiting time before the next call
Strategy 2: Retry with constant wait
Strategy 3: Retry with exponential Wait
Final Code: Abortable Retry with Expontial Back-off
The Functions should be abortable in production code.
References