DEV Community

Odd_Background_328
Odd_Background_328

Posted on

Retry Budgets Beat Free Capacity When 429s Multiply

A retry budget of zero means one initial attempt and no retries. It should not mean dropping the job without trying. Keep the number of retries separate from the total number of attempts when comparing two model lanes.

Suppose four jobs each get at most one retry. Two succeed immediately, one gets a 429 and then succeeds, and one gets a 429 on both attempts. There are six attempts, three completions and one unfinished job. Attempts per input job is 6/4, or 1.5. Attempts per completed job across the whole queue is 6/3, or 2, because that metric includes the unsuccessful job’s work. If a dashboard averages only over successful jobs, it will instead show 4/3. All three numbers answer different questions.

Put the deadline next to the budget

For each dequeued job, record its creation time and last acceptable completion time. Make the first attempt if there is budget and time left. After a rate limit, apply the provider’s retry instructions where supplied and add bounded delay when appropriate. Check the deadline before sleeping and again before dispatch. Do not retry a permanent rejection simply because attempts remain. HTTP 429 may include a Retry-After header; the status alone does not promise when capacity will return. RFC 6585

Compare on-time completions, terminal failures and work remaining, alongside attempts per input job. Splitting retries by cause will expose a queue that is repeatedly hitting one quota bucket while other traffic succeeds. Keep per-job limits and a shared limit on retry traffic. A thousand jobs with a small individual budget can still retry together.

A constant independent failure probability is a useful arithmetic exercise, but real quota windows correlate outcomes. A consecutive run of 429s should send you back to the quota’s scope and reset behavior before you use a geometric estimate to buy capacity. For a local experiment, replay the same sequence of synthetic statuses under both policies and report unfinished jobs as well as successes.

Test the counters against a fixed status sequence

Feed four synthetic jobs these responses in order: success, success, rate-limit then success, and rate-limit then rate-limit. Permit one retry per job. Expect six attempts, three completed jobs and one terminal failure. Repeat with zero retries: expect four attempts and two completions. A dashboard that reports equal totals in both runs is dropping attempts or terminal failures.

This article was created with AI assistance.

Top comments (0)