Rate limits and temporary outages

Networking Senior Swift 5.5+ iOS 16+ Reviewed By Alok Singh

Pick the fix

The server returns 429 with Retry-After: 30. What should the client do?

Options
Hint 1 of 1

What does Retry-After tell you?

Choose an answer, then open Show answer below to check it.

Show answer

Answer: A Pause matching requests for 30 seconds through a shared limiter, show cached data, then retry

Correct. It respects the server and keeps the UI useful.

Why not the others?
  • B Retry immediately. It makes the overload worse.
  • C Retry each request with its own 1-second backoff. Uncoordinated retries ignore the server's instruction.
  • D Log the user out. 429 means slow down, not an auth failure.

30-second answer

Treat 429 and 503 as signals: honour Retry-After, back off with jitter, and share one limiter across the app so every caller slows down together. Add a circuit breaker that stops calls for a while after repeated failures, coalesce duplicate requests, and show cached data with a clear offline or retry state instead of spinning forever.

Practise saying it · 45 s. No recording, just a timer

Explain how you handle rate limits.

Say your answer out loud, then check which of these points you covered:

  • Honour Retry-After
  • Shared limiter
  • Circuit breaker
  • Cached fallback

Deep dive

Coalesce identical in-flight requests so a screen doesn't fire the same call twice.

Prioritise user-visible requests over prefetches.

Log failure rates so you see outages before users report them.

Back off background refresh more aggressively than foreground.

Common mistakes

  • Each request retrying independently.
  • Ignoring Retry-After.

Senior take & follow-ups

Seniors design the client to cooperate with the server under stress.

Follow-up questions

Think of your answer first, then open the hint.

  1. What is a circuit breaker?

    Show hint

    After N failures, fail fast for a cool-down period, then try one request.

  2. Where does the limiter live?

    Show hint

    In the shared client, often an actor.

Suggest a fix if something here is wrong or out of date.