Client Retry Policy With Exponential Backoff, Jitter, and Retry-After

Last updated: November 29, 2026

Quick Overview

Write the retry wrapper an API client uses when calling a model endpoint: retry connection errors, timeouts, 429s, and 5xx responses with capped exponential backoff and full jitter, honor the server's Retry-After header, and stop at a total deadline. Do not retry client errors like 400 or 401.

OpenAI
Software Engineering Fundamentals
Software Engineer
OpenAI
November 29, 2026
Software Engineer
Phone Screen
Software Engineering Fundamentals
Easy

0

0

0 solved


Write the retry wrapper an API client uses when calling a model endpoint: retry connection errors, timeouts, 429s, and 5xx responses with capped exponential backoff and full jitter, honor the server's Retry-After header, and stop at a total deadline. Do not retry client errors like 400 or 401.

Every OpenAI SDK has to handle rate limits and transient overload gracefully, and a bad retry policy can turn a brief outage into a self-inflicted traffic storm. The interviewer wants to see you separate retryable from non-retryable failures and understand why jitter matters.

What the Interviewer Expects
  • Classifies status codes into retryable and not retryable
  • Uses capped exponential backoff with full jitter
  • Respects Retry-After as a minimum delay
  • Bounds both attempts and total elapsed time
  • Injects sleep, RNG, and clock so it can be tested
Key Topics to Cover
exponential backoff
jitter
HTTP status codes
rate limiting
resilience
How to Approach This
  1. Apply SOLID principles. Single Responsibility makes code testable, Open/Closed makes it extensible.
  2. Choose data structures based on access patterns, not familiarity.
  3. Prefer immutable data and message passing over shared mutable state for concurrency.
  4. Design APIs with RESTful conventions, versioning, meaningful errors, and pagination from day one.
Possible Follow-up Questions
  • When is it unsafe to retry a POST, and how do idempotency keys help?
  • How would a retry budget across the whole client prevent retry storms?
  • How should streaming responses that fail midway be retried?
  • What is the difference between full jitter and equal jitter?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice System Design Problems
Sample Answer
Requirements

Retry on network errors, 408, 409, 429, and 500 to 504. Raise immediately on other 4xx. At most max_attempts tries and deadline seconds total. Delay never shorter than Retry-After....

High-Level Design

Delay for attempt a is uniform(0, min(cap, base * 2^a)). Exponential growth backs off quickly from an overloaded service; the cap keeps waits sane; full jitter spreads synchronized clients so they...


Submit Your Answer
Markdown supported