modelling API rate limits as diophantine inequalities
You're allowed 10 requests per hour. Each task you run makes three attempts: initial call, retry after 10 minutes, and retry after 30 minutes.
What’s the maximum number of tasks you can safely run per hour?
Most engineers throw exponential backoff at the problem. And it works great in most cases! But can we, for the sake of having fun, be more mathematical about this?
In a way, this is just an integer feasibility problem.
the setup
Let’s define the retry pattern: [0, 10, 30]. Every task fires th...
Read more at vivekn.dev