System Design · Module 10
Consensus, coordination and distributed transactions
- Lessons
- 12
- Free
- 0
- Reading
- ~4 h
Your progress
0 / 12 lessons done
Sign in to trackLessons
- Consensus: getting nodes to agree on a valueReplicated databases and coordination services must preserve decisions when machines fail. Understanding consensus helps you evaluate their guarantees, failure behavior and operating costs.
- Raft: a consensus algorithm step by stepRaft appears inside databases and coordination systems. Understanding its boundaries helps you diagnose unavailable writes, stale reads and unsafe failover assumptions.
- Leader election: choosing a single coordinatorBackground schedulers and maintenance jobs often need one coordinator with automatic replacement. The difficult part is replacing that coordinator without trusting a paused or disconnected worker.
- Distributed locks and leasesBackground workers often need exclusive access to shared resources. Understanding leases helps you recover from crashes without assuming that an expired worker has stopped.
- Fencing tokens: protecting against stale lock holdersBackground workers can resume after losing a lease. Fencing lets a database or service reject their delayed writes instead of trusting the worker’s view of ownership.
- ZooKeeper and etcd: coordination servicesSchedulers, service discovery and configuration distribution need a shared authority. Coordination services provide that authority, but applications must still handle stale clients, interrupted watches and ambiguous results.
- Two-phase commit: atomic transactions across servicesA checkout can update several databases but still need one outcome. Two-phase commit explains both how that outcome is protected and why a failed coordinator can leave healthy databases waiting.
- Sagas: multi-step transactions with rollback stepsCheckout often changes several independently owned systems. Sagas make partial completion explicit and give engineers a recovery plan when one step fails.
- Transactional outbox: reliably publishing eventsAn order can be saved successfully while its fulfillment event disappears. The transactional outbox preserves the obligation to publish, even when processes crash or the broker is unavailable.
- Change data capture: streaming database changesSearch indexes and other derived stores must follow database changes without making every application request update several systems. CDC moves that work into a recoverable pipeline, with explicit limits around ordering, retention and recovery.
- Flash sales: preventing overselling of limited stockLimited-stock launches combine concurrent writes, payment delays and sudden overload. You need to preserve inventory without making customers wait behind requests that cannot succeed.
- Design: a concert ticket booking systemBooking systems combine scarce inventory with slow, uncertain payments. The same problems appear in travel reservations, appointments and limited-stock checkout.
Practise with
Terms this module teaches 32
Open glossaryCompensating operation
A new business operation that reverses an earlier effect when a multi-step process cannot complete.
Compensating transaction
A new transaction that counteracts a previously committed business action without restoring an entire earlier database snapshot.
Consensus
A protocol problem in which participants must choose one proposed value without making conflicting decisions, despite specified failures.
Coordination service
A service that maintains small pieces of shared state used to coordinate other systems, such as ownership, membership and configuration.
Coordination session
A continuing client relationship with a coordination service that can survive a temporary network disconnection.
Coordination watch
A subscription that tells a client about changes to coordination records; replay and notification behavior depend on the service.
Distributed lock
Shared permission used to coordinate access to a named resource across separate processes or machines.
Fencing token
An ordered ownership generation sent with operations so a resource can reject requests from an older owner after accepting a newer generation.
Idempotent consumer
A message handler designed so that processing a repeated message does not repeat its intended effect.
Inventory reservation
A durable assignment of available stock to a checkout attempt, usually until confirmation, cancellation or expiry.
Leader election
Selecting one participant to coordinate a role and selecting a replacement when ownership changes.
Lock authority
The logical service that atomically decides who owns a lock and whether ownership remains valid.
Logical decoding
PostgreSQL’s mechanism for interpreting recovery-log records as application-readable database changes.
Outbox relay
A worker that reads committed outbox events, publishes them, and records publication progress.
Owner token
A value identifying one lock acquisition, checked when renewing or releasing that acquisition.
Payment reconciliation
Checking a payment provider’s recorded outcome and bringing local booking and refund state into agreement with it.
Prepared transaction
An unfinished transaction whose state is preserved so it can follow a later commit-or-abort decision, including after a crash.
Raft
A consensus algorithm that uses leader elections and replicated logs to keep a group of state machines consistent through crashes and communication failures.
Raft commit index
The highest log position a node knows is committed. Entries through this position may be applied in order.
Raft term
A numbered election round used to identify leadership and reject outdated protocol messages. A term can end without electing a leader.
Replicated state machine
Replicas that apply the same ordered commands deterministically to produce the same state and results.
Replication slot
PostgreSQL state that tracks a replication stream and retains resources its reader may still need.
Saga
A multi-step workflow of locally committed transactions with explicit recovery actions for partial completion.
Saga choreography
A saga arrangement where participating services react to events and collectively implement the workflow without one controller owning its sequence.
Saga orchestration
A saga arrangement where a coordinator records workflow progress and decides which participant action runs next.
Seat hold
A durable, temporary reservation that gives one booking exclusive access to selected seats until its deadline or another terminal outcome.
Stock-keeping unit
An identifier for a particular sellable item or product variant whose inventory is tracked separately.
Store revision
A position in a store’s change history that can identify a snapshot boundary or the changes after it.
Transaction coordinator
The component that tracks a distributed transaction’s participants and manages its single commit-or-abort decision.
Transactional outbox
A record of messages to publish, saved in the same local transaction as the business change that creates them.
Two-phase commit
An atomic commitment protocol in which participants durably prepare their work before a coordinator records and distributes one commit-or-abort decision.
Znode
A record in ZooKeeper’s hierarchical namespace, with data and metadata such as version information.