Saga Pattern
ELI5 — The Vibe Check
The saga pattern is how you handle transactions that span multiple services. In a monolith, you'd wrap everything in one database transaction. In microservices, you can't do that. So instead, you break the transaction into steps: charge payment → reserve inventory → ship order. If step 2 fails, you run 'compensating actions' to undo step 1 (refund payment). It's like planning both the road trip and the backup plan for every stop.
Real Talk
The Saga Pattern manages distributed transactions across microservices by breaking them into a sequence of local transactions, each with a corresponding compensating transaction for rollback. Two implementations exist: choreography (services react to events) and orchestration (a central coordinator directs the flow). Sagas provide eventual consistency without distributed locks, trading the simplicity of ACID transactions for scalability and service autonomy.
When You'll Hear This
"Use the saga pattern for the order flow — payment, inventory, and shipping are separate services." / "The saga orchestrator handles rollbacks if any step fails."
Related Terms
ACID (Atomicity, Consistency, Isolation, Durability)
ACID is the four guarantees a reliable database makes about transactions. It is the reason you trust a bank's database with your money.
Event-Driven Architecture
Event-Driven Architecture is like a gossip network. When something happens (order placed!), it broadcasts the news.