Error Recovery and Graceful Degradation
You'll learn how to design systems that either recover from failures automatically or continue operating with reduced functionality when full recovery isn't possible.
The Core Idea
When errors occur in production, you have two choices: attempt recovery or accept partial failure. Error recovery means detecting a problem and automatically correcting it, allowing the system to return to normal operation. Graceful degradation means acknowledging that full functionality isn't available, but providing a reduced, still-useful experience instead of complete failure.
Think of it like a restaurant: if your stove breaks (error), you might reboot it (recovery). If that doesn't work, you can still serve salads and cold dishes (graceful degradation) rather than closing entirely.
Recovery Strategies
Retry with Backoff: Temporary network glitches or database locks often resolve themselves. Retry the operation a few times with increasing delays.
Fallback to Alternative: If one payment gateway fails, try another. If the primary database is down, read from a replica.
Circuit Breaker: After repeated failures, stop trying for a period to avoid cascading problems, then gradually test if recovery is possible.
Graceful Degradation Strategies
Feature Toggles: Disable non-critical features (recommendations, personalization) while keeping core functionality (checkout, login) working.
Cached Data: Serve slightly stale data from cache when the live source fails.
Default Values: Return sensible defaults instead of crashing—show a generic profile picture if the image service is down.
User Communication: Inform users honestly: "Search temporarily unavailable; browse our featured products instead."
The key is planning these strategies during design, not scrambling when production fails.
Key Takeaway: Design systems to either automatically recover from errors or consciously degrade functionality, ensuring users get the best possible experience even when something goes wrong.