Sub topic 1
How Dependencies Fail: Errors, Slowness, and Partial Outages
Prerequisites
Assume you have basic experience building a service that calls another service or database over a network. You should understand exceptions, HTTP requests, latency, and availability.
How dependencies fail
A dependency is a service, database, or external provider that your service needs. Dependencies fail in several ways:
- Errors: The dependency returns an error response, rejects a connection, or becomes unreachable.
- Slowness: The dependency eventually responds, but takes so long that requests queue up and consume resources.
- Partial outages: Some requests, users, regions, or operations fail while others continue to work.
These failures have different effects. A quick error lets your code respond or choose a fallback. An unbounded wait can tie up worker threads and cause your own service to fail. A partial outage can be harder to notice because health checks may pass while a particular feature is broken.
What graceful degradation means
Graceful degradation means keeping the most useful parts of a service available when a dependency fails. The service may return less data, omit an optional feature, or use an older cached result.
This differs from two other behaviors:
- Failing completely: The whole request or service becomes unavailable.
- Failing fast: The service stops waiting quickly and returns an error. This protects resources, but it does not provide useful fallback behavior.
- Degrading gracefully: The service responds within a limit and clearly returns a reduced result.
A degraded response should be intentional. For example, a product page might show product details without personalized recommendations. The response should also record that it used a fallback so operators and clients can distinguish it from a normal response.
Deciding what is essential and what can be dropped
Classify each dependency by the consequence of losing it:
| Dependency | If unavailable | Acceptable behavior |
|---|---|---|
| Payment authorization | Do not complete the purchase | Fail the transaction |
| Recommendations | Personalization is lost | Show popular items or nothing |
| Audit logging | Compliance risk | Queue safely or block the action |
A critical dependency is required for correctness, safety, security, or data integrity. A non-critical dependency supports convenience or enrichment. Define the degraded behavior for both before an outage occurs.
Exercise
A recommendation service is timing out while checkout still works. What should the product page do?
Show answer
Stop waiting within a timeout and show the product without recommendations, while recording a degraded response.