The main point of the backoff strategy is to distribute the failed message through different queues where each one has a default TTL (time to live, which means for how long a message will lie in a queue) value for its messages. Obviously, before a message is retried, it should arrive through an origin queue, which is our main queue for webhooks. If all attempts to trigger a webhook fail, we should send the failed message to a final queue that will have messages for further investigation.
Now we come to the exponential side of the moon. The queue TTL will receive a calculated value based on the following exponential backoff formula:
{interval} + {current_retry_attempt} ^ 4
If we apply the formula above to generate 10 TTL values, we will end with:
Current Attempt | Next Retry (seconds) | Total Elapsed (seconds) |
---|---|---|
1 | 61 | 61 |
2 | 76 | 137 |
3 | 141 | 278 |
4 | 361 | 594 |
5 | 685 | 1279 |
6 | 1356 | 2635 |
7 | 2461 | 5096 |
8 | 4156 | 9252 |
9 | 6621 | 15873 |
10 | 10060 | 25933 |