AR6: Reliability across services: deadlines, retries, idempotency, outboxes and contracts

Lesson 2 of 5 · reading 15–25 minutes; practice and project time is on the module page

Deadlines, retries and circuit breakers

🎯You'll be able to

Set a deadline on a call, retry with backoff and jitter where it's safe, and explain how a circuit breaker protects both sides.

🏠The everyday picture

If a shop's phone line is busy, you don't redial every second; you wait a little longer each time, and after a few tries you go in person or come back tomorrow.

📘What it really is

📝A worked example

Input: RasoiRoute's remote sender calling the notify service.

Steps:

  1. Deadline: 500 ms. An order can afford that; it can't afford 10 seconds.
  2. On timeout or a 5xx answer: don't retry inside the order request; put the message in the outbox (Lesson 4).
  3. On a 4xx answer (bad request, unknown template): don't retry at all; record it as failed, because repeating won't help.
  4. The outbox is drained later, with backoff between attempts.

Expected output: an order request that never waits more than about half a second for messaging, and no retry storm.

🌍Where it's used

📝Case scenario

A ticketing platform's services each retried failed calls five times with no backoff. When the seat service slowed during a big sale, the retries multiplied its load six-fold and it collapsed entirely. Fewer retries with backoff, and a circuit breaker, would have let it recover.

🖱️Try it

Write the waits for four retries with exponential backoff starting at 200 ms, then add a random jitter of up to 100 ms to each. Success: the waits grow, and two callers would almost never retry at the same moment.

⚠️Common mistakes

🛠️For your project

Project 2 sets timeoutMs (500 in the reference). Test 7 checks the order answers within 1.5 seconds when the service never responds.

✅Quick check

Why add jitter to retry waits?

Show the answer

So many callers don't retry at the same instant and overload the service again.

What are a circuit breaker's three states?

Show the answer

Closed (calls go through), open (calls stop and fail fast), half-open (one test call after a pause).

← PreviousNetworks fail in partial ways
ProLearners Assist