100% Free Forever
AI-Powered Learning
Industry Expert Content
Certificates & Badges
Learn At Your Own Pace
Architecture

Consensus Algorithms

Consensus algorithms let a group of distributed nodes agree on a single value or ordered log despite failures and network delays, underpinning leader election and replicated state machines.

Distributed Systems TheoryAdvanced11 min readJul 9, 2026
Analogies

Consensus Algorithms

Consensus is the problem of getting a set of distributed nodes to agree on a single value, or a single ordered sequence of values, even though nodes can crash, restart, or experience arbitrary network delays. It sounds simple, but the FLP impossibility result (Fischer, Lynch, Paterson, 1985) proves that no fully asynchronous consensus algorithm can guarantee both safety and termination if even one node may fail — so every practical consensus algorithm makes some timing assumption (like using timeouts) to make progress in practice, while still guaranteeing safety (never agreeing on two different values) under all conditions. Consensus is the foundation underneath distributed locks, leader election, configuration stores, and replicated logs — anywhere a cluster needs a single, agreed-upon source of truth despite individual node failures.

🏏

Cricket analogy: Third umpire reviews must reach a final verdict despite conflicting camera angles and signal delays; if the feed freezes mid-review, the umpire still can't declare two different outs for the same ball — a single, safe decision is non-negotiable even when technology stalls.

Paxos: The Original, Notoriously Hard Algorithm

Paxos, introduced by Leslie Lamport, was the first widely studied consensus algorithm proven correct under partial synchrony. It works in two phases: a 'prepare' phase where a proposer asks a majority of acceptors to promise not to accept any proposal older than the one it's about to send, and an 'accept' phase where the proposer sends its actual value and acceptors accept it if they haven't promised otherwise in the meantime. Paxos guarantees safety (only one value is ever chosen) as long as a majority of nodes are reachable, but it is famously difficult to implement correctly and even harder to extend to a continuously replicated log (Multi-Paxos), which is why it earned a reputation for being conceptually elegant but practically painful — most engineers encounter it via derivative systems (like Chubby or Spanner) rather than implementing it directly.

🏏

Cricket analogy: Paxos is like a captain first sending a runner to check with a majority of teammates that no one has already agreed to a different batting-order change, then only locking it in once that majority confirms — elegant but so fiddly most players only see it via the umpire's simplified final call.

Raft: Designed for Understandability

Raft, published by Diego Ongaro and John Ousterhout in 2014, was explicitly designed to be easier to understand and implement than Paxos while providing equivalent guarantees. Raft decomposes consensus into three clearly separated subproblems: leader election (nodes use randomized timeouts to elect a single leader when the previous one fails or none exists), log replication (the leader appends entries to its log and replicates them to followers, committing an entry only once a majority have stored it), and safety (mechanisms ensuring a newly elected leader always has all previously committed entries, so committed data is never lost or overwritten). Because the leader is the single point that orders all writes during its term, clients get a strong, easy-to-reason-about model: all state changes flow through one leader at a time, and Raft's leader election guarantees at most one leader can be active per term. Raft powers etcd, Consul, and CockroachDB's metadata layer, among many others.

🏏

Cricket analogy: Raft splits captaincy into clear jobs: randomized coin-toss-style timeouts elect a new captain when one steps down, the captain alone calls every shot during the innings, and rules ensure a newly appointed captain always knows the prior overs bowled, so no delivery's record is ever lost.

text
Raft leader election (simplified):

1. All nodes start as Followers with a randomized election timeout.
2. Follower's timeout expires without hearing from a Leader ->
   it becomes a Candidate, increments its term, votes for itself,
   and requests votes from all other nodes.
3. Each node votes for at most one Candidate per term (first-come,
   first-served), then resets its own timeout.
4. If a Candidate gets votes from a MAJORITY of nodes -> becomes
   Leader for that term, starts sending heartbeats.
5. If no Candidate gets a majority before timeouts expire again ->
   new election starts with a higher term (randomized timeouts
   make this eventually converge).

Log replication once a Leader exists:
[Client] -> [Leader] appends entry to its log
            [Leader] -> replicate to Follower A, Follower B
            Once a MAJORITY (Leader + 1 Follower of 3) have
            stored the entry -> Leader commits it and responds
            to the client, then notifies Followers to commit too.

Google's Chubby lock service (built on a Paxos-derived protocol) and its open-source descendants ZooKeeper (ZAB protocol, Paxos-inspired) and etcd (Raft) are the classic real-world consensus deployments: they don't store application data at scale, but they provide the small, highly-consistent 'source of truth' — locks, leader pointers, configuration — that the rest of a much larger, eventually-consistent system relies on to avoid split-brain scenarios.

Consensus vs. Coordination-Free Systems

Consensus is expensive: it requires a network round-trip to a majority of nodes for every committed decision, which adds latency and limits throughput compared to systems that avoid coordination entirely (like AP/eventually-consistent stores). This is why well-designed systems use consensus sparingly — for a small amount of critical metadata (leader pointers, cluster membership, configuration) — rather than routing every single application write through a consensus protocol. Databases like CockroachDB and Spanner use consensus (Raft or Paxos variants) per data shard/range, so consensus overhead is bounded and parallelized across many independent groups rather than being a single global bottleneck. This is also why production clusters are almost always sized 3, 5, or 7 nodes: a cluster survives f failures with 2f+1 total nodes, and an even-sized cluster (like 4) tolerates no more failures than the next smaller odd-sized one (3), so the extra node adds cost without added fault tolerance.

🏏

Cricket analogy: Running DRS for every single delivery would grind a match to a halt, so it's reserved for close calls only; likewise a franchise fields exactly 11 (not 12) starters because an extra player adds cost without letting the team survive any more injuries than 11 already does under the rules.

  • Consensus lets distributed nodes agree on a single value or ordered log despite crashes and network delays.
  • The FLP impossibility result means no purely asynchronous algorithm can guarantee both safety and termination; practical systems use timeouts to make progress.
  • Paxos was the original proven consensus algorithm but is notoriously hard to implement and extend correctly.
  • Raft achieves equivalent guarantees with an explicit focus on understandability, splitting the problem into leader election, log replication, and safety.
  • Consensus requires a majority (quorum) of nodes, which is why clusters are typically sized 3, 5, or 7 (odd numbers) rather than even.
  • Because consensus adds latency, production systems apply it narrowly (metadata, leader election, per-shard coordination) rather than to every write.

Practice what you learned

Was this page helpful?

Topics covered

#Architecture#SystemDesignStudyNotes#SoftwareEngineering#ConsensusAlgorithms#Consensus#Algorithms#Paxos#Original#StudyNotes#SkillVeris

Frequently Asked Questions

21 categories · pick one to explore

Where can I get free study notes for programming and tech subjects?
SkillVeris offers completely free study notes covering programming and tech subjects, with no signup fees or paywalls. The notes are structured by course and topic, written for quick understanding, and enriched with the Learn Through Hobbies analogy method, so you can revise concepts through cricket, music, gaming, cooking and more.
Are SkillVeris study notes good for exam revision?
Yes, the study notes are designed for efficient revision: each topic answers its heading immediately, keeps explanations concise, and links to related glossary terms and cheat sheets. Students preparing for university exams or certification tests use them as quick revision notes because they distil concepts without the padding of full textbooks.
What subjects do the free study notes cover?
The study notes span the platform's main domains, including AI and machine learning, Python and programming, web development, DevOps, cloud, security and databases. Coverage mirrors the 37 live courses, so notes exist for the topics you are actually studying, and new note sets are added as courses launch.
How are SkillVeris study notes different from regular textbooks?
The notes are answer-first, concise and free, whereas textbooks are long and often expensive. Each section explains one concept directly, then reinforces it through selectable hobby analogies like cricket or cooking. Notes also cross-link to the glossary, blog and cheat sheets, letting you jump to related material instantly instead of flipping pages.
Can I use the developer study material without creating an account?
The study notes are free to access, and SkillVeris does not charge anything for its developer study material at any point. Browsing notes is straightforward from the Study Notes section, and if you want progress tracking, certificates and AI Mentor conversations tied to your learning, a free account unlocks those extras.
Do the study notes explain concepts with analogies?
Yes, this is a signature SkillVeris feature. Study notes use the Learn Through Hobbies method, explaining technical concepts through analogies from twelve domains including cricket, music, gaming, photography, travel, movies, fitness, chess, cooking, finance, business and sports. You can switch the analogy domain instantly to whichever hobby makes the concept click.
Are the revision notes suitable for last-minute exam preparation?
Yes, revision notes on SkillVeris work well for last-minute preparation because every section states the answer in its first sentences, so skimming is genuinely effective. Pair them with the relevant cheat sheet for formulas and syntax, and use the glossary for any unfamiliar term you meet while cramming.
Is there free study material for AI and machine learning?
Yes, SkillVeris provides free study notes across its AI and ML catalogue, covering Python for AI, deep learning frameworks like PyTorch and TensorFlow, Hugging Face Transformers, Large Language Models, RAG, AI agents and MLOps. All of it is free, making it a strong resource for Indian students and global learners alike.
Can beginners understand the study notes, or are they for experts?
Beginners can absolutely use them. The notes are written in plain language, define terms as they appear, and lean on hobby analogies to make abstract ideas concrete. Difficulty scales with the underlying course level, so beginner-course notes stay gentle while advanced-course notes go deeper, and the glossary supports you throughout.
How do study notes connect with SkillVeris courses?
Study notes are organised by course and topic, so they map directly to the structured courses and their 24–40-lesson curriculum. Many learners study a lesson first, then use the matching notes for revision before module assessments and the final exam, where 80 percent is required to pass and earn the certificate.
Are there study notes for Python specifically?
Yes, Python is well covered through notes tied to the Python-focused courses, including Python for AI and ML. Topics span fundamentals through applied machine learning usage. You can reinforce the notes with Python practice in Code Lab, which runs code in your browser with no installation required.
Do the study notes include code examples?
Yes, study notes include code examples wherever a concept is best shown in code, alongside explanations, key points and analogies. Reading a snippet in the notes and then reproducing it yourself in Code Lab is an effective loop, since Code Lab lets you run code in the browser across six languages.
How often is new study material added to SkillVeris?
Study material grows alongside the course catalogue. Whenever new courses join the platform's 37 live courses, matching study notes, glossary entries and cheat sheets are added so the resources stay in sync. Existing notes are also refined over time, so it is worth revisiting topics you studied earlier.
Can I use SkillVeris notes to prepare for technical interviews?
Yes, the notes make excellent interview revision because they compress each concept into direct, answer-first explanations, which mirrors how you should answer interview questions. Combine them with the SkillVeris interview questions feature, which includes readiness scoring, to test whether your revision has actually made you interview-ready.
Are the study notes mobile-friendly for studying on the go?
Yes, the study notes are built to load fast and read comfortably on mobile devices, so you can revise during a commute or between classes. Sections are short and answer-first, which suits small screens, and analogy switching works on mobile too, letting you study anywhere without carrying books.
What is the difference between study notes and cheat sheets?
Study notes explain concepts in depth with context, examples and analogies, making them ideal for learning and revision. Cheat sheets are compact quick-reference summaries of syntax, commands and key facts, ideal once you already understand a topic. Most learners study the notes first, then keep the cheat sheet handy while coding.
Do study notes help if I am stuck on a course lesson?
Yes, reading the matching study notes often clarifies a lesson because the same concept is explained from a different angle, frequently with a different analogy. If you are still stuck, ask the AI Mentor, which answers 24/7 at Quick, Detailed or Deep-dive depth until the idea genuinely makes sense.
Is there free study material for DevOps and cloud topics?
Yes, SkillVeris carries free study notes for DevOps and cloud topics as part of its coverage across 37 live courses. The material suits learners following the DevOps Engineer or Cloud Engineer paths, and it links to related glossary terms and cheat sheets so you can revise the whole toolchain in one place.
Can school or college students in India use these notes for projects?
Yes, students across India and worldwide use SkillVeris notes for coursework, projects and exam preparation, and everything is free, which matters for student budgets. The notes explain concepts clearly enough to cite in project reports, and Code Lab lets you prototype the project code directly in your browser.
How should I combine study notes with other SkillVeris resources?
A proven loop: learn from a course lesson, revise with the matching study notes, look up unfamiliar terms in the glossary, keep the cheat sheet open while practising in Code Lab, and quiz yourself with interview questions. The AI Mentor fills any remaining gaps 24/7, at whatever depth you need.

What Learners Say

Real journeys from the SkillVeris community — swipe for more.

SkillVeris taught me Python through Cricket. Now I’m building real projects and feeling confident!
Arjun S. · B.Tech Student
The best platform for hobby-based learning. Concepts finally stick.
Priya R. · Data Analyst
I went from zero coding to a portfolio of projects — all by learning through my love for gaming. Landed my first internship!
Kabir M. · CS Undergraduate
Trending Topics50 popular tags — tap to explore
Trending CoursesAll 37 free courses — tap to browse