Docsity

Distributed Systems: Consistency, Replication and Fault Tolerance, Study Guides, Projects, Research of Distributed Programming and Computing

Toggle sidebar
bg1
Distributed Systems: Consistency, Replication and Fault Tolerance Page 1 of 6
Distributed Systems: Consistency, Replication and Fault
Tolerance
Building systems that keep working when parts of them do not
Computer Science | Undergraduate (Level 6) | December 2026
WHAT IS INSIDE
1. Core Concepts and Theoretical Frameworks
2. Models and failure
3. Consistency models and CAP
4. Replication and consensus
5. Transactions, exactly-once and operations
6. Comparative Summary Table
7. Real-World Case Studies
8. Common Exam Pitfalls and Essay Writing Tips
9. Practice Exam Questions with Model Answers
10. Glossary and Revision Plan
1. Core Concepts and Theoretical Frameworks
Distributed systems answers are marked on naming the guarantee a design provides and the cost it pays for it. The
table gives the models with their authors and the guarantee each one states.
Theory or model Scholar and
year Model or formula What it is used for
Happens-before and logical
clocks Lamport, 1978 a happens before b if a could causally
affect b; logical clocks order causally
related events
Reasoning about ordering
without a global clock
ACID transactions Harder and Reuter,
1983 Atomicity, consistency, isolation,
durability Transaction guarantees
CAP theorem Brewer, 2000;
Gilbert and Lynch,
2002
Under a network partition a system must
sacrifice consistency or availability Design trade-offs under
failure
PACELC Abadi, 2012 If partitioned, choose availability or
consistency; else choose latency or
consistency
Trade-offs in normal
operation
Two-phase commit Bernstein and
Goodman, 1981 Prepare then commit; blocking if the
coordinator fails Distributed transactions
Consensus: Paxos Lamport, 1998 Majority quorum agreement despite
crashes and delays Replicated state machines
Consensus: Raft Ongaro and
Ousterhout, 2014 Leader election, log replication and safety
rules designed for understandability Implementing replication
Quorum arithmetic Gifford, 1979 If read quorum plus write quorum
exceeds replicas, a read sees the latest
write
Tuning replica consistency
Idempotency and delivery
semantics Helland, 2012 At-least-once delivery plus idempotent
processing approximates exactly-once
effects
Messaging and retries
The examinable discipline is to state a guarantee precisely. 'The system is consistent' says nothing; 'a read after an
acknowledged write returns that write or a later value, unless a partition has occurred' says what the design
pf3
pf4
pf5

Partial preview of the text

Download Distributed Systems: Consistency, Replication and Fault Tolerance and more Study Guides, Projects, Research Distributed Programming and Computing in PDF only on Docsity!

Distributed Systems: Consistency, Replication and Fault

Tolerance

Building systems that keep working when parts of them do not Computer Science | Undergraduate (Level 6) | December 2026

WHAT IS INSIDE

  1. Core Concepts and Theoretical Frameworks
  2. Models and failure
  3. Consistency models and CAP
  4. Replication and consensus
  5. Transactions, exactly-once and operations
  6. Comparative Summary Table
  7. Real-World Case Studies
  8. Common Exam Pitfalls and Essay Writing Tips
  9. Practice Exam Questions with Model Answers
  10. Glossary and Revision Plan

1. Core Concepts and Theoretical Frameworks

Distributed systems answers are marked on naming the guarantee a design provides and the cost it pays for it. The table gives the models with their authors and the guarantee each one states.

Theory or model Scholar and year

Model or formula What it is used for

Happens-before and logical clocks

Lamport, 1978 a happens before b if a could causally affect b; logical clocks order causally related events

Reasoning about ordering without a global clock

ACID transactions Harder and Reuter, 1983

Atomicity, consistency, isolation, durability

Transaction guarantees

CAP theorem Brewer, 2000; Gilbert and Lynch, 2002

Under a network partition a system must sacrifice consistency or availability

Design trade-offs under failure

PACELC Abadi, 2012 If partitioned, choose availability or consistency; else choose latency or consistency

Trade-offs in normal operation

Two-phase commit Bernstein and Goodman, 1981

Prepare then commit; blocking if the coordinator fails

Distributed transactions

Consensus: Paxos Lamport, 1998 Majority quorum agreement despite crashes and delays

Replicated state machines

Consensus: Raft Ongaro and Ousterhout, 2014

Leader election, log replication and safety rules designed for understandability

Implementing replication

Quorum arithmetic Gifford, 1979 If read quorum plus write quorum exceeds replicas, a read sees the latest write

Tuning replica consistency

Idempotency and delivery semantics

Helland, 2012 At-least-once delivery plus idempotent processing approximates exactly-once effects

Messaging and retries

The examinable discipline is to state a guarantee precisely. 'The system is consistent' says nothing; 'a read after an acknowledged write returns that write or a later value, unless a partition has occurred' says what the design

actually provides and when it stops providing it.

2. Models and failure

A distributed system is a set of independent computers that appears to its users as one. The defining difficulty is that partial failure is normal: some nodes are slow, some are unreachable, and the network may be neither reliable nor ordered. The synchronous model bounds message delay and processing, which makes agreement solvable; the asynchronous model bounds neither, which makes it impossible in the presence of even one crash failure.

Failure models distinguish crash-stop , crash-recovery and Byzantine. Timeouts are the practical way to suspect failure, and they are always a guess: too short and healthy nodes are excluded, too long and recovery is slow. A logical clock or vector clock replaces physical time where ordering matters, because wall clocks disagree.

  • Partial failure - the defining property.
  • Asynchronous impossibility - agreement needs some timing assumption.
  • Timeouts are guesses - and design depends on them.
  • Vector clocks - causal order without synchronised time.

3. Consistency models and CAP

Consistency models describe what a reader may observe: linearisability (a single global order respecting real time), sequential consistency, causal consistency, and the weak models - eventual and read-your-writes - that trade guarantees for availability and latency. CAP says that under a network partition a system must choose between consistency and availability, but it is a statement about partitions, not a licence to be inconsistent in normal operation.

PACELC extends it: even when there is no partition, latency and consistency trade off. Quorum systems make the trade explicit: a write acknowledged by W of N replicas and read from R, with R + W > N, guarantees overlap. Strong eventual consistency through CRDTs allows concurrent updates to merge deterministically without coordination, which is why they suit collaborative editing.

  • Linearisable - the strongest practical model.
  • CAP governs partitions - not everyday operation.
  • Quorum - R plus W greater than N.
  • CRDT - merge without coordination.

4. Replication and consensus

Replication gives durability and read capacity, at the cost of keeping copies in step. Single-leader replication serialises writes and must handle failover - and a stale leader that still believes it leads is the dangerous case, resolved by fencing tokens. Multi-leader and leaderless designs accept conflicts and resolve them by last-write-wins, version vectors or application logic.

Consensus is agreement on a value despite failures. Paxos and Raft achieve it with a quorum and a leader; Raft's separation of leader election, log replication and safety is why it is easier to teach and to implement. Consensus requires a majority, so a three-node cluster tolerates one failure and a two-node cluster tolerates none - which is why even numbers are a design error.

  • Failover risk - the old leader must be fenced.
  • Quorum - majority, so odd cluster sizes.
  • Raft - leader, log, safety property.
  • Conflict resolution - a policy, and a product decision.

5. Transactions, exactly-once and operations

The case shows that strong consistency is a choice with a price, not an impossibility. The price is latency: waiting for clock uncertainty and coordinating across regions adds milliseconds to hundreds of milliseconds per commit, and it requires an infrastructure investment - GPS and atomic clocks in every data centre - that most organisations cannot replicate. Spanner is the right design for an inventory or financial ledger where a stale read is a business error, and the wrong design for a social feed.

The examinable point is that CAP is a statement about behaviour during partitions, not a prohibition on strong consistency; Spanner remains available in the sense that a majority partition continues to serve, while a minority partition does not accept writes.

Case 3: The AWS S3 outage, 2017

In February 2017 an operator command intended to remove a small number of servers from the S3 index subsystem was entered with a parameter that removed a much larger set, taking the index and placement subsystems offline for several hours and causing failures across many dependent services. The post-incident review described an operational error amplified by tooling that allowed a broad removal without sufficient safeguards.

The case is about blast radius and the control plane. Distributed systems fail in two ways: the data plane, where requests are served, and the control plane, where configuration and membership are changed. A control-plane error can remove capacity faster than the system can replicate around it, and dependencies between services turn a single failure into a cascade.

The lessons are design lessons: limit the effect of any single command, require confirmation proportional to impact, test the removal of capacity in a controlled way, and design dependencies so that a failure degrades rather than stops. For exam answers, it is the counterweight to the assumption that replication and automation make a system safe.

The three systems cover the axes of the module: availability under partition, consistency at a latency cost, and operational failure in the control plane.

8. Common Exam Pitfalls and Essay Writing Tips

The seven errors that cost the most marks

  • Treating CAP as a three-way choice. Partition tolerance is not optional in a network; the real choice is what to sacrifice when a partition occurs.
  • Claiming exactly-once delivery. Networks duplicate; what is achievable is at-least-once delivery with idempotent effects.
  • Ignoring clock skew. Physical clocks drift and cannot order events across machines without uncertainty bounds.
  • Retrying without idempotency. A retry that is not safe duplicates the effect, which is how double payments happen.
  • Assuming consensus is cheap. Each round needs a majority and a round trip; consensus is for metadata, not for every request.
  • Testing only the failure-free path. Partitions, slow nodes and partial failures are the subject.
  • Confusing availability with uptime. A system can answer every request with stale data and be available but wrong.

The pattern is a guarantee asserted rather than specified: the marks are for saying exactly what holds, and when it stops holding.

Where the literature disagrees The argument is about what CAP means and whether it should guide design. The strict reading is a theorem: during a partition a system cannot both return the latest value and answer every request. The practical critique is that partitions are rare, so the interesting trade-off is the everyday one between latency and consistency, which PACELC describes; and that 'pick two' has become a slogan that hides the per-operation choices real systems make. A second argument concerns microservices: decomposition buys independent scaling and failure isolation

at the cost of distributed transactions, which pushes designers towards sagas, idempotency and eventual consistency. The defensible position is that consistency is a spectrum chosen per operation and per data item, not a property of a system.

Writing the essay Structure design answers as guarantee, mechanism, cost, failure. State the guarantee the design provides, the mechanism that provides it, the cost it pays, and the failure in which the guarantee lapses. That four-part answer covers the mark scheme for almost any design question.

For comparison questions, use a table with the models as rows and consistency, availability, latency and coordination as columns, then argue from it. A comparison without a conclusion about which to use, and for what data, is only a list.

A worked application Scenario: design a ticket-booking service that must not oversell seats but must stay usable during a regional failure. The inventory is partitioned by event, each seat is a row with a version, and reservations are written with a conditional update, which gives per-seat linearizability without global coordination. A reservation is held for ten minutes with an expiry, and the client receives an idempotency key so a retry does not create a second hold. Payment is a separate service; the booking is confirmed by a saga that charges then confirms, with a compensating release if confirmation fails. During a partition, the majority side of each seat's replica set continues; the minority side rejects writes rather than overselling, which is the deliberate choice of consistency over availability for this data. Reads of event listings are served from a cache with a short TTL, where staleness is acceptable.

9. Practice Exam Questions with Model Answers

Each model answer below is written at the length a 20-25 mark question expects: a direct answer, the framework applied to the facts, and one limitation. Read the answer, cover it, and rewrite it from the question alone.

Question 1. Explain CAP with a concrete example of each choice. Model answer. CAP states that a distributed system facing a network partition cannot guarantee both linearizable consistency and availability for every request. Choosing consistency means a minority partition refuses reads or writes rather than returning a value that may be stale, which is what a bank ledger needs: a refused transaction is recoverable, a wrong balance is not. Choosing availability means every node answers, possibly with stale or conflicting data, which suits a shopping cart where a merge is harmless. The theorem is about the partition case, not about normal operation, and real systems choose per operation: a catalogue read may be eventually consistent while a payment write is strongly consistent.

Question 2. Compare Paxos and Raft as consensus protocols. Model answer. Both solve the same problem - agreement among a majority of replicas despite crashes and message loss - and both require a quorum, so both are unavailable to a minority partition. Paxos, described by Lamport in 1998, is the foundational protocol: a proposer gathers promises, then acceptances, and the safety argument rests on intersecting majorities. It is notoriously difficult to implement, and the multi-Paxos variant used in practice leaves leader election and log management underspecified. Raft, published in 2014, is designed for understandability: a strong leader, terms, a replicated log with a prefix property, and explicit rules for election and commitment. Raft's contribution is engineering rather than theory; it made correct implementations more common, which is why it underpins systems such as etcd and Consul.

Question 3. How would you make a payment retry safe? Model answer. The client generates an idempotency key per logical payment and sends it with every attempt. The server stores the key with the outcome of the first processing, in the same transaction as the payment record, and returns the stored outcome for any repeat, so a duplicate request does not create a duplicate charge. The key must be scoped to the account and expire only after the window in which retries can occur. The server must also handle the case where the first attempt is still in progress, returning a conflict rather than processing twice. Where the downstream provider has its own