Handling Dependency Unavailability
What you'll learn: How to keep your system functioning when the external services it depends on become slow, unreachable, or misbehave.
The Core Problem
Modern applications rarely work in isolation—they depend on databases, payment processors, email services, third-party APIs, and more. When these dependencies fail or become unavailable, your application faces a choice: crash completely or continue serving users with reduced functionality.
Dependency unavailability means an external service you rely on is either:
- Completely unreachable (network failure, server down)
- Responding too slowly (timeout scenarios)
- Returning errors (500 errors, invalid responses)
Strategies for Continuing Operation
Think of your application like a restaurant. If your seafood supplier doesn't deliver today, you don't close the restaurant—you mark seafood dishes unavailable and serve everything else.
1. Use Fallback Values
Return cached data, default values, or degraded responses when the real dependency fails. The user gets something rather than nothing.
2. Fail-Safe Defaults
As you learned in lesson 1107, design operations that default to safe, functional states. If your recommendation engine is down, show popular items instead of breaking the page.
3. Circuit Breakers
Stop calling a failing dependency (from lesson 1096) to avoid wasting resources and time. Return fallback responses immediately.
4. Bulkheads
Isolate the failure (lesson 1098) so one slow dependency doesn't consume all your system resources and affect other features.
5. Graceful Degradation
Disable non-critical features while keeping core functionality alive. Users can still checkout even if product reviews are temporarily unavailable.
The Mindset Shift
Treat dependency availability as probabilistic, not guaranteed. Design every integration point with the question: "What happens when this service isn't available right now?"
Key Takeaway: Handle dependency unavailability by combining fallbacks, circuit breakers, and graceful degradation—allowing your system to continue serving users with reduced functionality rather than failing completely.