question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Exponential backoff for retries

See original GitHub issue

Hi!!!

It’s a good experience of using huey. Now…

In our usage, each individual task will make a HTTP call to another server running somewhere else. It happens that that server may be overloaded at some peak time and I would get “503 Server Error”.

I was wondering whether an exponential backoff option for retry is useful here. Since if the fixed retry window is too small, it may fail soon if the overload period of the server is long. And if the fixed retry window is too large, it may just unnecessarily wait for too much if it’s some other issue caused the retry.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
coleifercommented, Oct 4, 2019

If you want to fiddle with task settings at run-time, you can request huey to pass the task instance into your task function, and modify it yourself.

Something like this?

@huey.task(retries=10, retry_delay=1, context=True)
def my_task(a, b, task=None):
    # task will be the task instance when the task is run by the consumer
    try:
        return do_something(a, b)
    except Exception as exc:
        task.retry_delay *= 1.15
        raise exc
0reactions
BSVoglercommented, Jul 15, 2022

Great, thank you!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error retries and exponential backoff in AWS
In addition to simple retries, each AWS SDK implements exponential backoff algorithm for better flow control. The idea behind exponential backoff is to...
Read more >
Implement retries with exponential backoff - Microsoft Learn
Retries with exponential backoff is a technique that retries an operation, with an exponentially increasing wait time, up to a maximum retry ......
Read more >
Understanding Retry Pattern With Exponential Back-Off and ...
The idea behind using exponential backoff with retry is that instead of retrying after waiting for a fixed amount of time, we increase...
Read more >
Better Retries with Exponential Backoff and Jitter - Baeldung
In this tutorial, we'll explore how we can improve client retries with two different strategies: exponential backoff and jitter.
Read more >
Use the exponential backoff method to retry requests
Use the exponential backoff method to retry requests,Key Management Service:Retry a request at fixed intervals within a specified period of ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found