Mostly Used Distributed System Patterns
M. Mohsin Ali
Experienced Engineering Manager | Passionate About Developing High-Performance Teams, Agile Methodologies, Technical Leadership and Innovation-Driven Solutions
Here is the brief explanation of 7 mostly used Distributed System Design Patterns.
1. Ambassador
The first is the "Ambassador". Think yourself as a manager and your assistant who is handling all your appointments and communication. Thats exactly what Ambassador pattern does for your application. It acts as a bridge for your app the services it communicates with. Offloading tasks as logging, monitoring or handling retries
For example, Kubernetes uses envoy as Ambassador to simplify communication between services.
This is not to be used when de-coupling your legacy/monolithic application. Use this when you want to add new features to the legacy but you don't want to touch the legacy system.
2. Circuit Breaker
This is a popular pattern for fault tolerance in microservices
The Circuit Breaker pattern works by wrapping a potentially dangerous or faulty operation in a circuit breaker object. The circuit breaker is designed to detect when the operation is failing or taking too long to complete.?
Generally following steps are taken:
When does the circuit trip?
领英推荐
3. CQRS(Command Query Responsibility Segregation)
CQRS is like having restaurant with separate lines for ordering food
By separating the write or command,?and read or query operations we can scale and optimise each independently.
An ecommerce platform might have?high read requests for products listings but fewer write requests for placing orders. CQRS allows each operation to be handled efficiently. This pattern becomes especially valuable in systems where read and write operations have different performance characteristics, with different latency or resource requirements
Command is referred to as write(Create, Update, Delete) operations and query is referred to as read operations.
This pattern basically suggests segregating the write operations from read operations because we usually have fewer write queries as compared to read queries.
4. Event Sourcing
Think of Event Sourcing as keeping the journal of life events. Instead of updating the record directly, we store events representing changes.
A banking application is an ideal scenario where we can implement Event Sourcing pattern. A customer starts with $100 in his bank account. That hundred dollar is stored in a column "total_amount = $100". If a customer withdraws $50, and the total_amount is calculated as $100 - $50 = $50 and the column is updated with $50 value. This update action, replaces the value $100 with $50 and now querying the database tells us the final amount but it doesn't tell us how we got there.
The customer might have withdrawn $20 and $30 or he might withdraw $90 and then deposited $70 but we don't know the complete trail.
So, the idea is instead of updating a record directly, we store events representing changes. This approach provides a complete history of the system and enables better auditing and debugging
5. Sharding
Sharding is like dividing a large pizza into smaller slices, making it easier to handle. It's a technique for distributing data across multiple nodes
Databases like MongoDB and Cassandra use sharding to handle large amounts of data efficiently.
8+y Sr. Full Stack Engineer Web3 | Solutions Architect (AWS) | Softwartist ????
1 年Lovely. I’d love it more if you add more scenarios where these can be applied. May be add a lil more depth to it. Keep them coming. ????