Distributed System Patterns
Microservices break things: Transactions, Consistency, and Reliability. Learn the patterns (Circuit Breaker, Saga, Outbox) we use to glue them back together.
What you will learn
- Survive failure with the Circuit Breaker and Bulkhead patterns
- Replace ACID transactions with Sagas (Orchestration vs Choreography)
- Solve the 'Dual Write' problem using the Transactional Outbox
- Guarantee exactly-once processing with Idempotency Keys
Moving from a monolith to microservices trades one set of problems for another. You gain deployment independence and fault isolation — but you lose two guarantees that make single-process systems easy to reason about: atomic transactions and reliable function calls. A network call is not a function call. It can time out, fail silently, succeed at the wrong moment, or trigger a retry that causes a duplicate.
This chapter covers five patterns that distributed systems teams reach for when those guarantees disappear.
The risk in a synchronous call chain is cascading failure. When Service A calls Service B and B is down, every request to A hangs for the full timeout — typically 30 seconds — filling A's thread pool until A itself crashes. The upstream caller then crashes too, and the failure propagates.
A circuit breaker wraps the downstream call with a three-state machine. After a threshold of consecutive failures, the circuit opens and subsequent requests fail immediately at 0ms — no network call is made. After a cooldown window, the circuit enters half-open state and allows a single probe request through. Success closes the circuit; failure reopens it.
Create a free account to read the full chapter — advanced chapters, progress tracking, and quizzes are free with sign-up.