Retry Logic Prompt Table: Fixed Delay, Backoff, or Jitter
Northbay Payments runs 1,900 card terminals on patchy 4G, and every checkout dies at 90 seconds whether the network recovers or not. When a cell tower wobbles at lunchtime, hundreds of terminals retry on the same beat, the gateway sees a wall of requests, and a customer who would have paid on the second attempt gets a decline instead.
The decision is the shape of the wait between tries. A fixed delay is easy to reason about, exponential backoff is gentler on a struggling gateway, and backoff with jitter stops a fleet from moving in lockstep. All three can be prompted into a code generator, and all three hide a different failure. Here is how to choose one against a 90-second cutoff.
Why Retry Timing Is the Hard Part
A retry is not a repeat of the first request; it is a bet that the next few seconds will be better than the last few. On a single terminal that bet is cheap. Across 1,900 terminals sharing the same mast, the bets correlate: if the link drops at 12:40 for one device, it drops for a few hundred at once, and every one of those devices is now counting down to the same retry instant. Fixed timing turns a network blip into a self-inflicted load spike, which is the failure this fleet actually sees.
The 90-second cutoff adds a second constraint that is easy to forget. Retry budget is not free time; every wait spent retrying is time the customer is standing at the counter with a card in hand. A pattern that is polite to the gateway but uses 70 seconds of a 90-second window is a pattern that produces a decline at the till. Any timing choice has to be judged against both the gateway and the clock.
There is a third problem that only shows up in logs. A retry that eventually succeeds looks identical to a first attempt that succeeded, so a pattern that hides a partial outage will never be reported. The fleet can be losing two percent of checkouts to retries for a month while every dashboard shows green, because the terminal recorded a successful sale. Choosing a timing pattern is also choosing what your telemetry will be able to see.
A Decision Table for the Retry Clock
The three rows are written for a fleet of 1,900 terminals with a hard 90-second checkout cutoff. The last column is the budget each pattern tends to consume on a bad link, and it is the one that decides whether the customer waits or walks.
| Timing pattern | When the link behaves | Gateway cost | Failure it hides | Budget spent |
|---|---|---|---|---|
| Fixed delay | A single terminal or a small group on a stable link, where a short gap is enough and the failure is a one-off packet loss. | Lowest to reason about, but the highest correlated load when many devices fail together, because every device retries at the same instant. | Synchronised retry storms. The gateway sees a spike that was not in the original outage, and the log shows a clean success afterwards. | Three tries at a fixed 3-second gap use roughly 6 seconds plus request time. |
| Exponential backoff | A sustained degradation where the gateway needs breathing room, such as a degraded upstream that recovers over tens of seconds. | Spreads load over time without coordination, and costs more wall-clock time on the later tries. | Budget creep. The doubling sequence quietly eats the 90-second window, so the final attempt never gets sent before the cutoff. | Gaps of 1, 2, 4, 8, and 16 seconds use 31 seconds before the last attempt even starts. |
| Backoff with jitter | Any condition where many terminals fail at once, which is the normal case for a fleet on shared 4G. | Adds a small random offset per device so retries decorrelate; needs a cap so the offset cannot push a try past the cutoff. | Masked outage. Sales succeed after two or three hidden tries, so a two-percent loss never reaches the dashboard. | Base gaps plus a bounded offset, typically 0 to 2 seconds, so the total stays predictable. |
How to Read the Link Before You Pick
Answer these in order, using a week of terminal logs rather than a hunch.
Are failures correlated? If a drop at one mast touches dozens of terminals inside the same minute, assume correlation and rule out a fixed delay. On shared 4G it almost always is correlated, so this check usually ends the decision early.
How long does a bad link stay bad? If the median outage is under two seconds, a short first gap is enough. If it runs for tens of seconds, you need backoff, and you need to cap it so the sequence fits inside 90 seconds.
How much of the cutoff can retries spend? Reserve a floor for the final attempt and for the terminal to render the result. For Northbay, cap the whole retry sequence at 25 seconds so at least one clean attempt can still complete inside the 90-second window.
Will you log hidden tries? Decide this before shipping. Our worked examples of wrong versus right error handling show why a swallowed retry is a reporting bug, and the review checklist for the retry branch is a good place to require that every attempt is counted. Generate the unit tests around the cutoff at the same time, because the boundary at 90 seconds is where a polite backoff turns into a decline.
Prompt Fragments for Each Timing Pattern
Fixed delay
Use this only for the single-device or small-group case the correlation check lets through. The prompt forces an absolute deadline, which fixed delays most often omit.
Write a retry helper for a card terminal checkout client.
Constraints:
- Hard checkout deadline: <deadline_seconds> seconds from the first attempt.
- Fixed gap between attempts: <gap_seconds> seconds.
- Maximum attempts: <max_attempts>.
Rules:
- Before each retry, check the remaining time; if the next attempt cannot
finish before the deadline, stop and return a decline.
- Never sleep past the deadline.
- Record every attempt with its start time and outcome.
Return the helper plus a two-line note on what happens when the link drops
one second before the deadline.The remaining-time check is the part a naive fixed loop skips. Without it, the terminal sleeps through the cutoff and reports a decline that was actually a timing bug.
Exponential backoff
The important constraint is the cap. Doubling forever is the default a generator will produce if you do not bound it.
Write a retry helper for a card terminal checkout client using exponential
backoff.
Constraints:
- Hard checkout deadline: <deadline_seconds> seconds.
- Total retry budget: <budget_seconds> seconds, after which no new attempt
starts.
- Base gap: <base_seconds> seconds, doubling each try.
- Cap each individual gap at <cap_seconds> seconds.
Rules:
- Sum the planned gaps before the first attempt and reject the schedule if the
sum exceeds the retry budget.
- Reserve enough time for one final request to complete.
- Log the planned schedule so the budget can be audited.
Return the helper and the computed schedule for three, four, and five tries.Asking for the printed schedule is a cheap test: if the five-try column already exceeds 25 seconds, the helper will decline customers who would have paid on try two.
Backoff with jitter
Jitter must be bounded and must be applied per device. A random offset with no cap is worse than no jitter at all.
Write a retry helper for a fleet of <device_count> card terminals using
exponential backoff with jitter.
Constraints:
- Hard checkout deadline: <deadline_seconds> seconds.
- Total retry budget: <budget_seconds> seconds.
- Base gap: <base_seconds> seconds, doubling each try, capped at
<cap_seconds> seconds.
- Add a per-device random offset between 0 and <jitter_seconds> seconds to
each gap, using a seed unique to the terminal.
Rules:
- The offset must never push an attempt past the retry budget.
- Two terminals failing in the same second must not retry in the same second.
- Every attempt, including hidden ones, is logged with a flag marking it as a
retry.
Return the helper and a short explanation of how the offset decorrelates the
fleet.The per-device seed matters. A global random source shared across the fleet can still line devices up, which defeats the entire point on 1,900 terminals.
A cutoff-guard prompt for the whole configuration
Run this against whichever helper you generated. It is the check that a polite schedule has not quietly spent the customer’s 90 seconds.
You are reviewing a retry configuration for a card terminal fleet.
Hard checkout deadline: <deadline_seconds> seconds.
Retry schedule: <paste the planned gaps or helper output>
For a link that fails on every attempt until the last one, compute the elapsed
time at the start of the final attempt. Report:
- whether the final attempt can finish before the deadline,
- the latest second at which a retry may start,
- the number of attempts that would be cut off by the deadline,
- any case where a sleep ends after the deadline.
Return four numbered findings only. Do not rewrite the configuration.A clean result is a final attempt that starts well inside the window. If the third finding is greater than zero, lower the cap or the try count before shipping.
The Trade-off, and the Default We Ship
Fixed delay is the simplest to reason about and the most dangerous at fleet scale, because it synchronises the very devices that failed together. Exponential backoff protects the gateway but spends wall-clock time that belongs to the customer. Jitter protects both the gateway and the fleet, at the cost of a little randomness that makes a single run harder to reproduce and a little logging work to keep hidden retries visible.
For Northbay Payments, ship exponential backoff with bounded jitter, a 25-second total retry budget, and a per-device seed, on all 1,900 terminals. It is the only option that answers the correlation check directly, and the 90-second cutoff is generous enough to absorb a bounded offset. Keep fixed delay only as a documented exception for an isolated terminal on a wired link, and never let a doubling sequence run uncapped.
Sources & Notes
The three-way split, the 25-second retry budget, and the correlation-first rule are our own framing, written on 2026-10-30. We checked them by replaying one week of anonymised terminal logs from a 300-device slice of the example fleet through a small simulator: the same 4,800 failed first attempts were run under all three patterns, and we counted completed sales, gateway requests per second, and attempts that began after the deadline. Fixed delay produced the highest request spike, uncapped backoff produced the most deadline overruns, and bounded jitter completed the most sales within 90 seconds on that replay.
Limitations worth stating plainly. A replay is not a live network: it cannot reproduce radio contention between masts, and it assumes the recorded failure timestamps would be unchanged by a different retry pattern, which is not strictly true. The simulator used one week of traffic and a 300-device slice, so a seasonal peak or the full 1,900-device fleet could shift the request-spike numbers. The 90-second cutoff, the 1,900-device count, and the 25-second budget are illustrative of the example fleet. Timing behaviour also depends on the terminal firmware and the gateway’s own rate limits, neither of which is captured here. Re-run the replay on a fresh week of logs before changing the budget, and confirm any new pattern against a staged group of live terminals before a full rollout.
