0
0
Microservicessystem_design~12 mins

Timeout pattern in Microservices - Architecture Diagram

Choose your learning style9 modes available
System Overview - Timeout pattern

The Timeout pattern helps microservices avoid waiting too long for responses from other services. It sets a maximum wait time for requests, so if a service does not respond in time, the caller can handle the delay gracefully. This improves system responsiveness and prevents cascading delays.

Architecture Diagram
User
  |
  v
Load Balancer
  |
  v
API Gateway
  |
  v
Service A (Caller) ---(Timeout)---> Service B (Callee)
  |                                |
  |                                v
  |                             Database
  |
  v
Response to User
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 appropriate services and enforces policies
Service A (Caller)
service
Sends requests to Service B and applies timeout to avoid waiting indefinitely
Service B (Callee)
service
Processes requests and queries the database
Database
database
Stores persistent data accessed by Service B
Request Flow - 10 Hops
UserLoad Balancer
Load BalancerAPI Gateway
API GatewayService A (Caller)
Service A (Caller)Service B (Callee)
Service B (Callee)Database
DatabaseService B (Callee)
Service B (Callee)Service A (Caller)
Service A (Caller)API Gateway
API GatewayLoad Balancer
Load BalancerUser
Failure Scenario
Component Fails:Service B (Callee)
Impact:Service B does not respond within timeout period causing Service A to abort waiting and return an error or fallback response to the user.
Mitigation:Service A uses the timeout pattern to stop waiting after a set time and can return a default response or error message. Circuit breaker or retries can be added to improve resilience.
Architecture Quiz - 3 Questions
Test your understanding
Which component enforces the timeout to avoid waiting too long for a response?
AService A (Caller)
BAPI Gateway
CLoad Balancer
DDatabase
Design Principle
The Timeout pattern improves system responsiveness by limiting how long a service waits for another service's response. This prevents one slow or failing service from causing delays across the system, enhancing overall reliability and user experience.