



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




CS 6450 - Distributed Systems | Lecture notes (wk 5 + 6) Topics: consensus, Paxos, Raft, fault tolerance, CAP
Fundamental problem in distrib. computing. Given a set of processes, each w/ an initial value, they all need to AGREE on a single output value. Formal properties (from lecture):
Different types, in order of increasing badness:
Lamport's algorithm. Originally described in "The Part-Time Parliament" (1989, but not published until 1998 bc reviewers didn't like the Greek parliament story lol)
Three roles:
Two phases: Phase 1 (Prepare/Promise):
Basic Paxos only decides one value. Real systems need a sequence of decisions (replicated log). Multi-Paxos optimizes: elect a stable leader, skip Phase 1 for subsequent slots (as long as leader doesn't change). Problem: lots of underspecified details in original paper - leader election, log gaps, state transfer for new replicas. This is why Raft was invented.
Ongaro & Ousterhout 2014. Goal: understandability. Decomposes into 3 subproblems: leader election, log replication, safety. Key structural choices vs Paxos:
Terms - monotonically increasing integers. Each term starts w/ an election. States: Follower -> Candidate -> Leader (or back to Follower)
Leader receives client request -> appends to local log -> sends AppendEntries to followers -> once majority acknowledge, marks entry as committed -> applies to state machine -> responds to client AppendEntries also includes prevLogIndex and prevLogTerm for consistency check. Follower rejects if its log doesn't match at that point. Leader then decrements nextIndex and retries (log matching property ensures convergence). Committed = safely replicated on majority. NEVER overwritten. Raft guarantees committed entries appear in all future leaders' logs.
State Machine Safety: if a server has applied a log entry at index i, no other server applies a different entry at index i.
Raft never commits entries from prev terms by counting replicas - only commits entries from CURRENT term by counting, which implicitly commits all earlier entries (Figure 8 in paper shows why this matters - tripped me up on hw3)
Log grows forever otherwise. Solution: snapshots. Server periodically snapshots state machine state + last included index/term. Discards log up to that point. Leader can send InstallSnapshot RPC to lagging followers. Snapshot includes enough info to rebuild membership config too.
Brewer 2000 (conjecture), proved by Gilbert & Lynch 2002. In a distributed system, can have at most 2 of 3:
Problem: coordinator failure. If coord crashes AFTER sending prepare but BEFORE sending commit, participants are STUCK (they voted yes and can't release locks). This is the "blocking" problem. 3PC (three-phase commit) tries to fix this by adding a pre-commit phase. Non-blocking in some failure scenarios but not network partitions. Rarely used in practice. Modern approach: Paxos/Raft-based transaction managers (coordinator itself is replicated). Spanner does this w/ Paxos groups per shard + 2PC across shards.
Lamport clocks: each process maintains a counter. On event, increment. On send, piggyback clock. On receive, take max of local + received, then increment. Problem: Lamport clocks only capture -> (happened-before), NOT the reverse. a->b implies L(a) b iff V(a) < V(b) (componentwise <=, at least one strict)