Skip to content
Back to categories

Distributed Systems

Algorithms for consensus, logical and physical clocks, leader election, replication, and cluster partitioning.

Distributed systems algorithms coordinate state across networked nodes without shared memory, providing quorum consensus, causal and physical clock synchronization, leader election, conflict-free replication (CRDTs), and minimal-disruption key routing.

Distributed Systems· O(n log n)

Consistent Hashing Load Balancing

Distributed hash ring partitioning scheme with virtual nodes that maps both cache servers and keys onto a 32-bit/64-bit circle so node joins or failures remap only O(K/N) keys.

Concept & PseudocodeIntermediate2 links
Distributed Systems
Distributed Systems· O(N) messages (1 RTT quorum commit)

Raft Distributed Consensus

Maintains a replicated state-machine log across a cluster via leader election (randomized 150–300ms timeouts, §5.4.1 up-to-date log check) and majority-quorum AppendEntries replication.

Verified CodeAdvancedFormula4 links
Distributed SystemsConsensusReplicationQuorum
Distributed Systems· O(N) messages (1 RTT in Multi-Paxos)

Paxos Consensus

Reaches fault-tolerant distributed consensus across asynchronous replicated servers using two-phase Prepare/Promise and Accept/Accepted quorum rounds.

Concept & PseudocodeAdvancedFormula1 links
Distributed SystemsConsensusReplicationQuorum
Distributed Systems· O(1) per event

Lamport Logical Clocks

Orders events across distributed processes without synchronized physical clocks using a monotonically increasing scalar logical counter.

Concept & PseudocodeBeginnerFormula3 links
Distributed SystemsConsensusClassic
Distributed Systems· O(N) per message

Vector Clocks

Tracks exact causal history across N distributed nodes using an N-element counter vector to detect both causal ordering and concurrent conflicts.

Concept & PseudocodeIntermediateFormula4 links
Distributed SystemsConsensus
Distributed Systems· O(1) per poll

Cristian's Algorithm

Synchronizes a client's physical wall clock with a reference time server by measuring round-trip network delay and setting time to T_server + RTT / 2.

Concept & PseudocodeBeginnerFormula4 links
Distributed SystemsClock SynchronizationPhysical TimeNetworking
Distributed Systems· O(N)

Berkeley Algorithm

Synchronizes physical clocks across a cluster without an external UTC time source by polling all nodes, discarding outlier skews, and adjusting each node to the fault-tolerant average time.

Concept & PseudocodeIntermediateFormula3 links
Distributed SystemsClock SynchronizationPhysical TimeFault Tolerance
Distributed Systems· O(M log M)

Marzullo's Algorithm (NTP Clock Selection)

Finds the smallest confidence interval intersecting the maximum number of noisy time-server intervals in O(M log M) time, forming the core of NTP clock selection.

Concept & PseudocodeIntermediateFormula2 links
Distributed SystemsClock SynchronizationNtpInterval Sweep
Distributed Systems· O(N^2) messages

Bully Algorithm

Elects a coordinator in a distributed system by having any node that detects leader failure challenge all higher-ID nodes, so the live process with the highest numeric ID wins.

Concept & PseudocodeBeginnerFormula4 links
Distributed SystemsLeader ElectionFault ToleranceCoordination
Distributed Systems· O(N log N) messages (Chang-Roberts)

Ring Leader Election (Chang-Roberts)

Elects the highest-ID leader among processes arranged in a unidirectional logical ring by forwarding only the maximum candidate ID around the ring.

Concept & PseudocodeBeginnerFormula2 links
Distributed SystemsLeader ElectionRing TopologyCoordination
Distributed Systems· O(N) merge across N replicas

CRDT G-Counter & PN-Counter

Conflict-free replicated counter that allows offline or partitioned replicas to increment (G-Counter) and decrement (PN-Counter) concurrently and merge without a central server via element-wise maximum.

Concept & PseudocodeBeginnerFormula3 links
Distributed SystemsCrdtEventual ConsistencyReplication
Distributed Systems· O(|tags|) state merge

CRDT OR-Set (Observed-Remove Set)

Conflict-free replicated set that resolves concurrent offline add and remove operations deterministically (add-wins) by tagging each added element with a unique token.

Concept & PseudocodeIntermediateFormula3 links
Distributed SystemsCrdtEventual ConsistencyReplication
Distributed Systems· O(N)

Rendezvous Hashing (Highest Random Weight / HRW)

Assigns each key to the server node s that maximizes hash(key, s), achieving uniform load and minimal O(K/N) key remapping when servers join or leave without maintaining a virtual-node ring.

Concept & PseudocodeBeginnerFormula1 links
Distributed SystemsHashingLoad BalancingSharding