5. What is the Saga Pattern?
Answer:
The Saga Pattern manages distributed transactions across multiple microservices by breaking them into a series of local transactions. Each local transaction updates the database and publishes an event or message to trigger the next transaction. If a step fails, compensating transactions are executed to undo the changes.
Benefits:
- Maintains data consistency without distributed transactions.
- Supports long-running business processes.
- Enhances fault tolerance in distributed systems.
Use Case:
Ideal for complex business operations like order processing in e-commerce, where multiple services (inventory, payment, shipping) need to coordinate actions.
6. What is the Bulkhead Pattern?
Answer:
The Bulkhead Pattern isolates components or services into separate pools, so that if one fails, the others continue to function. This prevents a failure in one part of the system from cascading to others.
Benefits:
- Enhances system resilience by containing failures.
- Improves resource utilization and fault isolation.
- Allows for graceful degradation of services.
Use Case:
Useful in systems where services have varying levels of criticality, ensuring that non-critical service failures do not impact critical functionalities.
7. What is the API Composition Pattern?
Answer:
The API Composition Pattern involves aggregating data from multiple microservices into a single response. A composite service makes calls to various services and combines the results for the client.
Benefits:
- Simplifies client interactions by providing a unified response.
- Reduces the number of client-side requests.
- Encapsulates the complexity of data aggregation.
Use Case:
Applicable in scenarios where clients need to display data from multiple services, such as assembling user profiles from various microservices.
8. What is the Service Discovery Pattern?
Answer:
The Service Discovery Pattern enables services to find and communicate with each other without hard-coded IP addresses or endpoints. It can be implemented using a service registry where services register themselves and discover others.
Benefits:
- Facilitates dynamic scaling and service updates.
- Reduces configuration complexity.
- Enhances system flexibility and resilience.
Use Case:
Essential in cloud environments with dynamic service instances, ensuring that services can locate and interact with each other reliably.
👉The Next Questions-3: MICROSERVICES PATTERN