In this blog post I’m going to show you how you can use an exponential backoff algorithm in combination with a stopping supervisor strategy. In many cases you would like to retry some ‘dangerous operation’, something that can crash, for instance a call to some external service.
The OneForOneStrategy andAllForOneStrategy supervisor strategies have two arguments for a retry window; maxNrOfRetries and withinTimeRange can be used to define a maximum amount of retries within a maximum time range. This retry mechanism retries as soon as possible and does not wait between retries.
In some cases you would like the retry to be delayed so that the failing service does not get overloaded with unnecessary retries; it might be busy recovering and that might take some time. Instead of overloading the failing service with the same request we would like to use an algorithm that decides to wait longer if the dangerous operation keeps failing.
Exponential truncated backoff is such an algorithm which is also used in network congestion avoidance. The algorithm is quite simple:
Read more







