Paxos Consensus Interview Questions
Paxos consensus algorithm interview questions covering the classic distributed consensus protocol.
Q1: How does Paxos consensus work?
Answer:
Paxos is a consensus algorithm for distributed systems that ensures agreement among nodes even with failures.
Sequence Diagram:
Overall Flow Diagram:
Individual Node Decision Diagram:
Paxos Phases:
Phase 1: Prepare
- Proposer sends
prepare(n)with proposal numbern - Acceptors respond:
- If
n > highest_seen: Promise not to accept proposals <n, return highest accepted value - Otherwise: Reject
- If
Phase 2: Accept
- If majority promise: Proposer sends
accept(n, v)with valuev - Acceptors accept if
n >= highest_seen - If majority accept: Consensus reached
Key Properties:
- Safety: Only one value can be chosen
- Liveness: Eventually reaches consensus (if no failures)
- Fault Tolerance: Works with up to (n-1)/2 failures
Example:
1class PaxosNode:
2 def __init__(self, node_id):
3 self.node_id = node_id
4 self.highest_seen = 0
5 self.accepted_value = None
6 self.accepted_proposal = 0
7
8 def prepare(self, proposal_num):
9 if proposal_num > self.highest_seen:
10 self.highest_seen = proposal_num
11 return {
12 'promise': True,
13 'accepted_proposal': self.accepted_proposal,
14 'accepted_value': self.accepted_value
15 }
16 return {'promise': False}
17
18 def accept(self, proposal_num, value):
19 if proposal_num >= self.highest_seen:
20 self.highest_seen = proposal_num
21 self.accepted_proposal = proposal_num
22 self.accepted_value = value
23 return {'accepted': True}
24 return {'accepted': False}
Use Cases:
- Distributed databases
- Configuration management
- State machine replication
Related Snippets
- Bitcoin (Nakamoto) Consensus Interview Questions
Bitcoin consensus algorithm interview questions covering Proof-of-Work (PoW) and … - Byzantine Fault Tolerance (BFT) Consensus Interview Questions
Byzantine Fault Tolerance (BFT) consensus algorithm interview questions covering … - Cardano Interview Questions - Easy
Easy-level Cardano interview questions covering blockchain basics, Plutus, and … - Cardano Interview Questions - Hard
Hard-level Cardano interview questions covering advanced optimization and formal … - Cardano Interview Questions - Medium
Medium-level Cardano interview questions covering advanced Plutus development … - Consensus Algorithms Comparison Interview Questions
Consensus algorithm comparison and general implementation interview questions. … - Cosmos Chain Operations Interview Questions - Easy
Easy-level Cosmos chain operation interview questions covering chain operations, … - Cosmos Chain Operations Interview Questions - Hard
Hard-level Cosmos chain operation questions covering advanced algorithms, … - Cosmos Chain Operations Interview Questions - Medium
Medium-level Cosmos chain operation questions covering advanced chain … - Cosmos SDK Interview Questions - Easy
Easy-level Cosmos SDK interview questions covering chain code, SDK basics, and … - Cosmos SDK Interview Questions - Hard
Hard-level Cosmos SDK interview questions covering advanced SDK internals, … - Cosmos SDK Interview Questions - Medium
Medium-level Cosmos SDK interview questions covering advanced module … - Ethereum Proof-of-Stake Consensus Interview Questions
Ethereum Proof-of-Stake consensus algorithm interview questions covering Casper … - Ouroboros (Cardano) Consensus Interview Questions
Ouroboros consensus algorithm interview questions covering Cardano's … - Polkadot (NPoS) Consensus Interview Questions
Polkadot consensus algorithm interview questions covering Nominated … - Polkadot Interview Questions - Easy
Easy-level Polkadot interview questions covering blockchain basics, Substrate, … - Polkadot Interview Questions - Hard
Hard-level Polkadot interview questions covering advanced optimization and … - Polkadot Interview Questions - Medium
Medium-level Polkadot interview questions covering advanced Substrate … - Solana Interview Questions - Easy
Easy-level Solana interview questions covering blockchain basics, programs, and … - Solana Interview Questions - Hard
Hard-level Solana interview questions covering advanced optimization, security, … - Solana Interview Questions - Medium
Medium-level Solana interview questions covering advanced program development, … - Solana Proof of History Consensus Interview Questions
Solana consensus algorithm interview questions covering Proof of History (PoH) … - Tendermint Consensus Interview Questions
Tendermint consensus algorithm interview questions covering the Byzantine Fault … - Web3 Interview Questions - Easy
Easy-level Web3 interview questions covering blockchain fundamentals, Ethereum, … - Web3 Interview Questions - Hard
Hard-level Web3 interview questions covering MEV, zero-knowledge proofs, … - Web3 Interview Questions - Medium
Medium-level Web3 interview questions covering DeFi, advanced Solidity, …