LyraLearn AI Learning Platform
Exams
← Module 5 Β· API and Integration Design
🎧 Listen

Resilience Questions

The scenario arrives as a complaint: "The state licensing API we depend on is flaky β€” slow some afternoons, down for minutes at a time. Users see spinners and 500s. What do you do?" The rubric behind it has four boxes β€” timeouts, retries with backoff, circuit breakers, idempotency β€” and one meta-box: do you understand these protect your app from their outage, not the other way around.

Timeouts first, always

Start here, because everything else is meaningless without it: "First I'd make sure every outbound call has an explicit timeout." HttpClient defaults to 100 seconds β€” say that number; it signals real-world experience. A request thread pinned for 100 seconds per call is how a dependency's slowness becomes your thread-pool starvation and your outage. Pick a timeout from the dependency's observed p99, not from vibes, and mention cancellation tokens flowing through the call chain so abandoned requests actually stop.

Retries β€” the part everyone gets half right

Retry transient failures only: timeouts, 408, 429, 5xx, connection resets. Never retry 400 or 401 β€” the same request will fail the same way. The words the interviewer is listening for: exponential backoff with jitter and a small, bounded attempt count (2–3). Explain jitter in one sentence: if a thousand clients retry on the same schedule, they stampede the recovering service in synchronized waves. Name the tool β€” Polly, via Microsoft.Extensions.Http.Resilience (AddStandardResilienceHandler() gives you the whole pipeline) β€” but make clear you understand the policy, not just the NuGet package.

Then the key follow-up: "What if the retried call was a POST that creates a payment record?" This is your idempotency key cue: the client sends a unique key per logical operation, the server stores it and returns the original result on replay. Retries are only safe when the operation is idempotent β€” by HTTP semantics or by engineering.

Circuit breakers and failing gracefully

When the dependency is down, retries make it worse. A circuit breaker watches the failure rate, opens after a threshold (fail fast, no calls), then half-opens to probe recovery. The half of the answer that actually differentiates candidates: what does the user see while the circuit is open? A cached last-known verification result, a "verification pending" status that a background job resolves later, a degraded read-only view β€” pick one and say it. Failing fast is a tool; graceful degradation is the goal.

Answers that fall flat

Practice prompts

🧠 Quiz yourself on this lesson →

Ask the AI Tutor

Grounded in the course lessons β€” it cites its sources and says when it doesn't know.