0
0
Microservicessystem_design~12 mins

Fallback pattern in Microservices - Architecture Diagram

Choose your learning style9 modes available
System Overview - Fallback pattern

The fallback pattern helps microservices handle failures gracefully by providing alternative responses when a service is down or slow. It ensures the system remains responsive and improves user experience by avoiding complete failure.

Architecture Diagram
User
  |
  v
Load Balancer
  |
  v
API Gateway
  |
  v
Service A (Primary Service) <-----> Cache
  |
  v
Fallback Service (Backup Service)
  |
  v
Database
Components
User
client
Initiates requests to the system
Load Balancer
load_balancer
Distributes incoming requests evenly to API Gateway instances
API Gateway
api_gateway
Routes requests to services and applies fallback logic
Service A (Primary Service)
service
Main service handling business logic and data retrieval
Cache
cache
Stores recent responses to reduce load and latency
Fallback Service (Backup Service)
service
Provides alternative responses when primary service fails
Database
database
Stores persistent data for services
Request Flow - 12 Hops
UserLoad Balancer
Load BalancerAPI Gateway
API GatewayCache
CacheAPI Gateway
API GatewayService A (Primary Service)
Service A (Primary Service)Database
DatabaseService A (Primary Service)
Service A (Primary Service)Cache
Service A (Primary Service)API Gateway
API GatewayUser
API GatewayFallback Service (Backup Service)
Fallback Service (Backup Service)API Gateway
Failure Scenario
Component Fails:Service A (Primary Service)
Impact:Primary service is unavailable or slow, causing request failures or delays
Mitigation:API Gateway detects failure or timeout and routes requests to Fallback Service to provide alternative responses, maintaining system responsiveness
Architecture Quiz - 3 Questions
Test your understanding
Which component decides to use the fallback service when the primary service fails?
ACache
BLoad Balancer
CAPI Gateway
DDatabase
Design Principle
The fallback pattern improves system resilience by providing alternative responses when a primary service fails. It uses the API Gateway to detect failures and route requests to a backup service, ensuring users receive timely responses even during partial outages.