All entries

    API Polling with Exponential Backoff and Retry-After

    A fixed retry interval makes many clients return together after a rate limit.

    Hourglasses and a request chart stand beside a robot in a greenhouse
    Conceptual pixel-art illustration.

    A fixed retry interval makes many clients return together after a rate limit. Combine randomized delay, a finite attempt budget and the server’s requested retry time.

    Build the example

    Treat successful queued responses as ordinary polling and transient 429 or 503 responses as retry candidates. Read Retry-After as either a number of seconds or an HTTP date. For invalid or past dates, use the local delay. Calculate an exponential ceiling with a cap, pick a random delay inside it, then respect a valid server-provided minimum. If that delay would exceed the job deadline, end the attempt and show a resumable state.

    In a simple clock fixture, put the first request at time zero, the second after the required delay and a terminal response after the third. Capture scheduled waits, not just requests that reached the server. The distinction exposes loops that schedule a replacement timer after an abort even when no further request happens.

    Teaching example
    delayMs = Math.max(serverMinimumMs, rng() * Math.min(8000, 500 * 2 ** attempt))

    Watch the failure boundary

    Keep the exponential state local to one job so a throttled export does not slow an unrelated screen. Record the delay and the failure class in development logs, with no request credentials. Treat permission errors and missing jobs as actionable outcomes. Retry handling should live in one layer so a query library and a network wrapper do not multiply attempts.

    Verify the behavior

    Stub three responses with an injected clock and random source. For attempt 2 with a 500 ms base, a random value of 0.5 and Retry-After of 5 seconds, expect 5 seconds. Abort during the wait and confirm no request fires. Check both attempts and elapsed wall time so a slow server cannot keep the loop alive indefinitely.

    FURTHER READING

    Sources

    Technical references checked .

    END OF ENTRY / 33
    Eeshan Singh with Big Ben in London
    BEHIND THE JOURNAL

    Eeshan Singh

    I’m Eeshan Singh Pokharia, an AI Full Stack Developer and CoFounder of UltraFit360. I work across AI features, full-stack product development, and web and mobile experiences—from Figma and frontend interactions to the systems behind them.

    Keep the exponential state local to one job so a throttled export does not slow an unrelated screen. Record the delay and the failure class in development logs, with no request credentials. Treat permission errors and missing jobs as actionable outcomes. Retry handling should live in one layer so a query library and a network wrapper do not multiply attempts.

    Meet the author
    THE CONVERSATION

    Your side of the story.