What Is Saga Pattern?
The Saga pattern is a microservices design pattern that manages distributed transactions by splitting them into a sequence of local steps with compensating actions to maintain consistency if failures occur.
When to Use
Saga is used when a business process spans multiple services, such as order processing, payment, and shipping. It ensures each step can either succeed or be rolled back without needing a single global transaction.
Example
An e-commerce order might reserve stock, charge payment, and arrange delivery. If delivery fails, Saga automatically triggers compensations: refund payment and release stock.
Want to build real system design intuition?
Explore: Grokking System Design Fundamentals Grokking the System Design Interview Mock Interviews with ex-FAANG engineers
Why Is It Important
It ensures eventual consistency across services without a heavy global transaction manager, improving scalability and fault tolerance.
Interview Tips
Explain Saga simply (like the e-commerce example), then highlight compensation logic, eventual consistency, and how it differs from atomic transactions. Mention pros and cons to show depth.
Trade-offs
Pros: Higher resilience, service autonomy, and scalability. Cons: Added complexity, eventual consistency delays, and more code for compensations.
Pitfalls
Common mistakes include forgetting compensation steps, assuming atomicity, or overusing Saga where a single service transaction would be simpler.
GET YOUR FREE
Coding Questions Catalog
$197

$78
$78