Coders In Hoods
  • Courses
  • Roles
  • Blog
  • Setup

Coders In Hoods AI Academy

Every course is free. Sign in to start, and your progress, quiz scores and bookmarks follow you.

AI Academy

  • Courses
  • Paths
  • Setup guides
  • How we teach

Role roadmaps

  • AI Engineer
  • Forward Deployed Engineer
  • Machine Learning Engineer
  • All roles

Coders In Hoods

  • The agency
  • Coaching for teams
  • Blog
  • LinkedIn
  • X (Twitter)

Contact

codersinhoods@gmail.com

© Coders In Hoods · since 2019

Course overview

Scaling AI Systems

Free · sign in to start and track progress

1 · Throughput under limits

  • 1Rate limits and quotas
  • 2Concurrency and flow control
  • 3Retries, backoff and overload

    Exercise answers

    • Answer: Simulate a retry storm and stop it
    • Answer: A circuit breaker with deadlines in front of a flaky mock
  • 4Backpressure, load shedding and batching

2 · Latency, resilience and capacity

  • 5Latency engineering for agents
  • 6Response caching and failover
  • 7Load testing and capacity planning
CapstoneMonth-end readiness for an agent fleetReference implementation

Module 1 · Throughput under limits · Lesson 3

Retries, backoff and overload

Classify every failure a model call can produce, retry only what can succeed, with capped exponential backoff, jitter, deadlines and retry budgets, and avoid the retry storms that turn a ten-second provider blip into a long outage.

75 min 1 video 3 exercises 7-question quiz Answers
Setup for the exercises:Install Claude CodePython with uv

By the end of this lesson you can

  • Classify model-call failures (429 variants, 529, 5xx, timeouts, mid-stream errors, refusals) into retry, wait, fail over or stop
  • Implement capped exponential backoff with full jitter that honours retry-after and an end-to-end deadline
  • Compute retry amplification across layers and bound it with a single retry layer and a retry budget
  • Explain metastable failures and how retries sustain an overload after its trigger has gone
  • Reason about what a retried model call costs and repeats, including tool side effects

On this page

  • Intuition: everyone redialling at once
  • Step 1: classify before you retry
  • Step 2: backoff with full jitter
  • Worked example: the ten-second blip
  • Honour retry-after
  • Step 3: one retry layer, with a budget
  • Step 4: deadlines and circuit breakers
  • Code: one retry policy for model calls
  • What a retry repeats
  • Misconceptions and limits
  • Connections
  • Summary
  • Sources & further reading
  • Quiz

In this lesson

  1. 01Intuition: everyone redialling at once
  2. 02Step 1: classify before you retry
  3. 03Step 2: backoff with full jitter
  4. 04Step 3: one retry layer, with a budget
  5. 05Step 4: deadlines and circuit breakers
  6. 06Code: one retry policy for model calls
  7. 07What a retry repeats
  8. 08Misconceptions and limits
  9. 09Connections
  10. 10Summary

Sources & further reading

  • Metastable Failures in the WildPaper · Huang, Magnusson, Muralikrishna, Estyak, Isaacs, Aghayev, Zhu, Charapko · 2022OSDI 2022. A study of 22 metastable failures from 11 organisations, including at least 4 of 15 major AWS outages in a decade. Read the definitions of triggers and sustaining effects; retries are the textbook sustaining effect.
  • Handling Overload (Site Reliability Engineering, chapter 21)Lab research · Alejandro Forero Cuervo · Google · 2016Read "Deciding to retry". It gives the per-request cap of three attempts and the per-client retry budget of 10%, which bounds retry load at about 1.1 times normal.
  • Errors (Claude API docs)Docs · AnthropicEvery HTTP error type, what the SDK retries by default, the long-request guidance and request IDs.
  • Python SDK (Claude API docs)Docs · AnthropicThe "Retries" and "Timeouts" sections. The SDK retries connection errors, 408, 409, 429 and 5xx twice by default, and times out after 10 minutes.
  • Streaming messages (Claude API docs)Docs · AnthropicThe "Error events" and "Error recovery" sections. Errors can arrive mid-stream after a 200, and only text can be resumed.
  • Exponential Backoff And JitterArticle · Marc Brooker · AWS · 2015The classic simulation of why backoff alone doesn't stop synchronised retries and how full, equal and decorrelated jitter compare. Short and still the best reference.
Free · sign in to start

Sign in to keep reading.

Free, no card. We use your account to save progress, quiz scores, bookmarks and occasionally send updates from our team.

  • 10 more sections
  • 3 hands-on exercises
  • A 7-question quiz
  • Progress, quiz scores and bookmarks