Stage 4 · Provision
Resilience Patterns
Graceful Degradation
Fallback data, partial responses, static modes, and brownout controls during dependency outages.
What Is Graceful Degradation?
Graceful degradation is the ability of a system to continue functioning at a reduced level when a dependency fails. Instead of returning errors for everything, the system serves what it can and degrades specific features. This provides a better user experience than complete failure.
Fallback Patterns
- Cached fallback — Serve stale cached data when the primary source is down.
- Default fallback — Return a sensible default (empty list, zero balance).
- Partial feature — Disable non-critical features, keep core functionality.
- Read-only mode — Disable writes, continue serving reads.
def get_recommendations(user_id):
try:
# Primary: ML-based recommendations from recommendation-service
recommendations = recommendation_service.get(user_id)
cache.set(f"recs:{user_id}", recommendations, ttl=300)
return recommendations
except ServiceUnavailable:
# Fallback: Last cached recommendations
cached = cache.get(f"recs:{user_id}")
if cached:
metrics.increment("recommendations.fallback_cached")
return cached
# Final fallback: Popular items (static list)
metrics.increment("recommendations.fallback_popular")
return get_popular_items()The fallback chain degrades from personalized recommendations to cached data to static popular items. Each level provides a worse but functional experience.
Partial Responses
When one component of a response is unavailable, return what you have and indicate what is missing. The user sees a partially loaded page instead of an error. This is better than failing completely.
{
"user": { "id": "123", "name": "Alice" },
"orders": { "available": true, "count": 5 },
"recommendations": { "available": false, "reason": "service_unavailable" },
"notifications": { "available": true, "unread": 3 }
}The response includes all available data and marks unavailable components. The frontend renders what it has and shows placeholder UI for missing data.
Static Mode
Static mode serves pre-generated, static content when the dynamic backend is unavailable. A news site might serve a cached homepage. An e-commerce site might serve product pages from CDN cache. This provides a read-only experience during outages.
Brownout Controls
Brownout is a controlled degradation under high load. Instead of failing completely, disable non-essential features to preserve core functionality. This is like dimming lights (brownout) to prevent a total blackout.
class FeatureController:
def __init__(self):
self.features = {
"personalized_feed": True,
"real_time_notifications": True,
"analytics_tracking": True,
"recommendations": True,
"social_sharing": True,
}
def apply_brownout(self, level: str):
if level == "light":
self.features["analytics_tracking"] = False
elif level == "medium":
self.features["analytics_tracking"] = False
self.features["recommendations"] = False
elif level == "heavy":
self.features["analytics_tracking"] = False
self.features["recommendations"] = False
self.features["real_time_notifications"] = False
self.features["social_sharing"] = FalseBrownout levels progressively disable non-essential features. This preserves core functionality while reducing load on struggling dependencies.
Graceful degradation should be designed, not improvised. Define which features are essential and which are disposable. Build degradation into the architecture from the start.
Mark this lesson complete to store local progress and unlock a cleaner resume path the next time you visit.