Retry with Exponential Backoff

Oct 25, 2023

There can be scenarios where your application is talking to another app or service that might be having a transient failure.

For example, your app might be making a call to the wallet service to update the user’s balance. But the wallet service might be down, or simply just undergoing maintenance.

In this case, a common technique used is retry with exponential backoff. When a request fails with a transient failure (network error / 5xx errors), you can implement an exponential backoff, that is — if the first retry is after 1 second, the second will be after 2 seconds, then 4 seconds and so on. Some systems add a constant timeout, and a randomness factor to avoid overwhelming the other system.

A common example of retry with exponential backoff is the Gmail UI when it tries to reconnect to the internet.