QA
Intermediate LevelREST APIs & Web Services

How do Fallback Responses and Graceful Degradation maintain client availability during outages?

❓ Interview Prompt: Explain Graceful Degradation, static fallbacks, caching stale responses, and maintaining UI availability when downstream API services fail.

Graceful Degradation ensures an application remains functional even when non-critical downstream microservices fail:

Implementation Strategies:

•
Stale Cache Fallback: If recommendations microservice times out, return stale cached recommendations from Redis.
•
Static Fallback: If personalized user profile fails, return default anonymous guest settings.
•
Degraded Response Payload: Omit non-critical fields instead of returning '500 Internal Server Error'!

Code Implementation Example

typescript
export async function getProductPage(productId: string) {
  const product = await db.products.findById(productId);
  
  let reviews = [];
  try {
    reviews = await fetchReviewsService(productId);
  } catch (err) {
    // Graceful degradation: Log error and return empty reviews array instead of failing request!
    logger.warn('Reviews service unavailable, degrading response gracefully', { productId });
  }

  return { ...product, reviews };
}
💡Gracefully degrading response payloads when secondary microservices fail.
🎯 Interview Key Takeaway

Implement graceful degradation by returning stale cached data or omitting non-essential fields when sub-services fail.

#Graceful Degradation#Fault Tolerance#Resilience#Intermediate
Back to all REST APIs & Web Services Questions→

More REST APIs & Web Services Interview Questions

Beginner LevelREST APIs & Web Services

What is HTTP Method Idempotency and how do you implement Idempotency Keys for REST APIs?

Beginner LevelREST APIs & Web Services

What are standard HTTP Status Codes (200, 201, 204, 400, 401, 403, 404, 409, 429, 500, 503)?

Beginner LevelREST APIs & Web Services

What are HTTP Verbs (GET, POST, PUT, PATCH, DELETE) and when to use PUT vs PATCH?