Every Call Needs a Plan B
any remote call can fail: timeout, error, circuit open.
code without a fallback:
recs = recommendationService.get(user) ← throws?
page dies with it.
with fallback:
try: recs = recService.get(user)
catch: recs = popularItemsCache.get() ← plan B, always ready
the fallback is chosen AT DESIGN TIME,
per call, by asking: "what's an acceptable answer
when this dependency is absent?"
The Fallback Taxonomy
| Type | Example | Freshness |
|---|---|---|
| Cached value | last-known recommendations | stale but relevant |
| Default/static | trending list, generic content | impersonal |
| Alternative source | secondary provider, read replica | near-current |
| Computed approximation | estimated delivery date | honest-ish |
| Empty-but-valid | hide section, empty list | clean |
| Queued deferral | ”will process shortly” | delayed not lost |
ordering principle: prefer CLOSER-TO-TRUTH fallbacks;
degrade to defaults only as needed. cache-first ladders:
live → short-cache → long-cache → static default → omit
Fallbacks That Lie Are Bugs
integrity rules from degradation apply per-call:
✗ payment gateway down → fallback to "mark paid"
(never! queue + retry + visible pending instead)
✗ inventory timeout → assume in-stock silently
("usually right" corrupts trust when wrong at checkout)
✓ shipping estimate timeout → show RANGE with "estimate" label
✓ fraud-service down → allow + flag for async review
(risk-ACCEPTANCE decision, made consciously)
every fallback is a RISK DECISION.
money/identity/legal claims: fail visibly.
content/convenience: degrade freely.
Engineering the Pattern
□ WRAP AT THE CLIENT: resilience library or generated client
applies fallback uniformly; business code stays clean
□ FALLBACK METRICS: track fallback-rate per dependency —
sustained elevation = incident signal (users on plan B
while dashboards look "fine")
□ EXPIRE THE CRUTCH: cached fallbacks carry age limits;
week-old "recommendations" become noise
□ TEST THE PLAN B: chaos-drill dependencies OFF and verify
fallbacks engage correctly (they rot otherwise!)
Interview Framing
“Walk me through your design’s behavior when each external call fails” scored shape: per-dependency fallback table (dependency → plan B → staleness/risk class), explicit integrity boundary sentence, fallback-metrics observability, chaos-testing note. Interviewers probe exactly this because designs are judged by their worst-day behavior, not their happy-path diagrams — have the table ready before they ask.
Premium Content
Unlock Fallbacks and all premium lessons with a subscription.
All premium lessons
Ad-free experience
Priority support
From ₹199.99/year — See plans