Key patterns for resiliency in Microservices Architecture
I wrote application architecture principles a few years ago when I headed the application architecture group. I found it on my old Miro board.
Most of the above principles are still valid and effective. Most organizations implement microservice architecture in some of their projects, primarily when they focus on modernizing their landscape from legacy systems.
Similarly, a few years back, I wrote patterns for microservices architecture and categorized them into different categories. Look at some of the significant microservices patterns below.
This needs to be refreshed now. I want to detail resiliency patterns more with my learning by implementing a microservices architecture.
Resiliency in microservices architecture refers to the system’s ability to handle failures and disruptions gracefully without affecting overall performance or availability. Since microservices are distributed, independent services communicating over a network are more susceptible to failures such as network outages, service crashes, or performance bottlenecks. A resilient microservices system can continue functioning or degrade gracefully when some components fail.
Critical Aspects of Resiliency in Microservices:
Importance of Resiliency in Microservices:
How to Achieve Resiliency:
Resiliency in microservices architecture is achieved through various patterns and practices, such as:
1. Circuit Breaker Pattern
How it works: The pattern has three states:
Closed: Requests usually flow, assuming the service is healthy.
Real-life Example: Netflix’s Hystrix library (now retired but still widely discussed) used the Circuit Breaker pattern extensively. For instance, if a video recommendation service was slow or down, Hystrix would stop routing requests, and users would be presented with a default list of trending content.
2. Retry Pattern
How it works:
领英推荐
A configurable delay (or backoff strategy) is used between retries to avoid flooding the service with immediate retries.
Real-life Example: In payment systems like Stripe, if a transaction processing service times out due to network instability, the system retries the request a few times before giving up. This helps in cases where temporary outages are expected but should not cause a permanent failure.
3. Timeout Pattern
How it works:
Each service call is assigned a maximum duration for how long it can take. If the service doesn’t respond within that window, the request is canceled, and the system can either retry or use a fallback.
Real-life Example: In an online ordering system like Grubhub, if a request to the payment service takes too long, the system times out the request and tries an alternative payment method or notifies the user about the delay. This prevents users from waiting endlessly.
4. Bulkhead Pattern
How it works:
Resources are partitioned into separate “bulkheads.” For example, each service might be assigned a separate pool of threads or connections.
Real-life Example: In a hotel booking system, a surge in requests to the room availability service (e.g., during holiday seasons) might overwhelm its resources. By applying the Bulkhead pattern, the hotel search and payment services won’t be affected, allowing users to continue searching or making payments even if availability checks are delayed.
5. Fallback Pattern
How it works:
When a service call fails, a pre-defined fallback response is returned.
Real-life Example: In a ride-hailing app like Uber, if the fare estimation service fails, the system might show an average fare for similar routes instead of leaving the user without any information.
Full article on https://medium.com/techartifact-technology-learning/key-patterns-for-resiliency-in-microservices-architecture-992966edbd67
Principal Architect, Clinical at Boston Scientific
5 个月Great work Vinay, pretty informative!
Developing AI-Powered Solutions | LLMs & Cloud Enthusiast, Senior Solution Architect, Emerging Technologies
6 个月Very informative, Vinay
VP and Head of Strategy Europe @ Novigo | Chief Architect
6 个月Great details about the patterns Vinay Kumar
Enterprise Architect, author, founder of alaraph.com
6 个月well done, Vinay!