System Design: Distributed Systems Fundamentals
Master core distributed systems concepts including physical vs logical time, consensus algorithms (Raft, Paxos), commit protocols (2PC/3PC), distributed locks, and fault tolerance.
1. What Makes a System "Distributed"?
A distributed system is a collection of autonomous computing nodes connected via a network that coordinate their actions by passing messages, presenting themselves to end-users as a single coherent system.
Core Advantages of Distributed Systems
- Horizontal Scalability:Add commodity compute nodes to handle linear growth in traffic and data storage.
- High Availability & Fault Tolerance:If a single server hardware host crashes, remaining cluster nodes take over transparently.
- Low Latency (Geo-Distribution):Deploy server nodes physically closer to global users across multiple data centers.
2. Distributed System Challenges (Network Partitions & Clock Sync)
Unlike single-machine software execution, distributed systems operate over unreliable physical networks subject to packet loss, message reordering, and physical clock drift.
Distributed Systems Challenges: Network Partitions & Logical Clocks
System DesignVisualizing physical clock skew challenges and logical event ordering using Lamport and Vector clocks
[
{
"id": "ds-box1",
"type": "rectangle",
"x": 30,
"y": 40,
"width": 400,
"height": 280,
"strokeColor": "#ef4444",
"backgroundColor": "#fef2f2",
"fillStyle": "solid",
"strokeWidth": 2,
"strokeStyle": "solid",
"roughness": 0,
"opacity": 100,
"roundness": {
"type": 3
},
"seed": 12000,
"version": 1,
"versionNonce": 12001,
"isDeleted": false
},
{
"id": "ds-box1-text",
"type": "text",
"x": 40,
"y": 166,
"width": 380,
"height": 28,
"strokeColor": "#991b1b",
"backgroundColor": "transparent",
"fillStyle": "solid",
"strokeWidth": 1,
"strokeStyle": "solid",
"roughness": 0,
"opacity": 100,
"seed": 12002,
"version": 1,
"versionNonce": 12003,
"isDeleted": false,
"text": "Network Partition & Partial Failure",
"fontSize": 14,
"fontFamily": 5,
"textAlign": "center",
"verticalAlign": "middle",
"originalText": "Network Partition & Partial Failure"
},
{
"id": "ds-nodeA",
"type": "rectangle",
"x": 50,
"y": 90,
"width": 140,
"height": 60,
"strokeColor": "#3b82f6",
"backgroundColor": "#dbeafe",
"fillStyle": "solid",
"strokeWidth": 2,
"strokeStyle": "solid",
"roughness": 0,
"opacity": 100,
"roundness": {
"type": 3
},
"seed": 12004,
"version": 1,
"versionNonce": 12005,
"isDeleted": false,
"boundElements": [
{
"type": "text",
"id": "ds-nodeA-text"
}
]
},
{
"id": "ds-nodeA-text",
"type": "text",
"x": 60,
"y": 106,
"width": 120,
"height": 28,
"strokeColor": "#1e40af",
"backgroundColor": "transparent",
"fillStyle": "solid",
"strokeWidth": 1,
"strokeStyle": "solid",
"roughness": 0,
"opacity": 100,
"seed": 12006,
"version": 1,
"versionNonce": 12007,
"isDeleted": false,
"text": "Node A (US-East)\nClock: 12:00:00.005",
"fontSize": 11,
"fontFamily": 5,
"textAlign": "center",
"verticalAlign": "middle",
"originalText": "Node A (US-East)\nClock: 12:00:00.005",
"containerId": "ds-nodeA"
},
{
"id": "ds-broken",
"type": "arrow",
"x": 190,
"y": 120,
"width": 80,
"height": 0,
"strokeColor": "#ef4444",
"backgroundColor": "transparent",
"fillStyle": "solid",
"strokeWidth": 2,
"strokeStyle": "dashed",
"roughness": 0,
"opacity": 100,
"points": [
[
0,
0
],
[
80,
0
]
],
"endArrowhead": "arrow",
"seed": 12008,
"version": 1,
"versionNonce": 12009,
"isDeleted": false
},
{
"id": "ds-partition",
"type": "rectangle",
"x": 200,
"y": 95,
"width": 60,
"height": 50,
"strokeColor": "#ef4444",
"backgroundColor": "#fee2e2",
"fillStyle": "solid",
"strokeWidth": 2,
"strokeStyle": "solid",
"roughness": 0,
"opacity": 100,
"roundness": {
"type": 3
},
"seed": 12010,
"version": 1,
"versionNonce": 12011,
"isDeleted": false,
"boundElements": [
{
"type": "text",
"id": "ds-partition-text"
}
]
},
{
"id": "ds-partition-text",
"type": "text",
"x": 210,
"y": 106,
"width": 40,
"height": 28,
"strokeColor": "#991b1b",
"backgroundColor": "transparent",
"fillStyle": "solid",
"strokeWidth": 1,
"strokeStyle": "solid",
"roughness": 0,
"opacity": 100,
"seed": 12012,
"version": 1,
"versionNonce": 12013,
"isDeleted": false,
"text": "Network\nPartition!",
"fontSize": 10,
"fontFamily": 5,
"textAlign": "center",
"verticalAlign": "middle",
"originalText": "Network\nPartition!",
"containerId": "ds-partition"
},
{
"id": "ds-nodeB",
"type": "rectangle",
"x": 270,
"y": 90,
"width": 140,
"height": 60,
"strokeColor": "#3b82f6",
"backgroundColor": "#dbeafe",
"fillStyle": "solid",
"strokeWidth": 2,
"strokeStyle": "solid",
"roughness": 0,
"opacity": 100,
"roundness": {
"type": 3
},
"seed": 12014,
"version": 1,
"versionNonce": 12015,
"isDeleted": false,
"boundElements": [
{
"type": "text",
"id": "ds-nodeB-text"
}
]
},
{
"id": "ds-nodeB-text",
"type": "text",
"x": 280,
"y": 106,
"width": 120,
"height": 28,
"strokeColor": "#1e40af",
"backgroundColor": "transparent",
"fillStyle": "solid",
"strokeWidth": 1,
"strokeStyle": "solid",
"roughness": 0,
"opacity": 100,
"seed": 12016,
"version": 1,
"versionNonce": 12017,
"isDeleted": false,
"text": "Node B (EU-West)\nClock: 12:00:00.001",
"fontSize": 11,
"fontFamily": 5,
"textAlign": "center",
"verticalAlign": "middle",
"originalText": "Node B (EU-West)\nClock: 12:00:00.001",
"containerId": "ds-nodeB"
},
{
"id": "ds-skew-text",
"type": "rectangle",
"x": 50,
"y": 180,
"width": 360,
"height": 120,
"strokeColor": "#ef4444",
"backgroundColor": "#fee2e2",
"fillStyle": "solid",
"strokeWidth": 2,
"strokeStyle": "solid",
"roughness": 0,
"opacity": 100,
"roundness": {
"type": 3
},
"seed": 12018,
"version": 1,
"versionNonce": 12019,
"isDeleted": false,
"boundElements": [
{
"type": "text",
"id": "ds-skew-text-text"
}
]
},
{
"id": "ds-skew-text-text",
"type": "text",
"x": 60,
"y": 219.375,
"width": 340,
"height": 41.25,
"strokeColor": "#991b1b",
"backgroundColor": "transparent",
"fillStyle": "solid",
"strokeWidth": 1,
"strokeStyle": "solid",
"roughness": 0,
"opacity": 100,
"seed": 12020,
"version": 1,
"versionNonce": 12021,
"isDeleted": false,
"text": "Clock Drift Challenge:\nPhysical wall clocks drift by milliseconds.\nSystem cannot rely on physical timestamps to determine event causality ordering.",
"fontSize": 11,
"fontFamily": 5,
"textAlign": "center",
"verticalAlign": "middle",
"originalText": "Clock Drift Challenge:\nPhysical wall clocks drift by milliseconds.\nSystem cannot rely on physical timestamps to determine event causality ordering.",
"containerId": "ds-skew-text"
},
{
"id": "ds-box2",
"type": "rectangle",
"x": 450,
"y": 40,
"width": 420,
"height": 280,
"strokeColor": "#2563eb",
"backgroundColor": "#eff6ff",
"fillStyle": "solid",
"strokeWidth": 2,
"strokeStyle": "solid",
"roughness": 0,
"opacity": 100,
"roundness": {
"type": 3
},
"seed": 12022,
"version": 1,
"versionNonce": 12023,
"isDeleted": false
},
{
"id": "ds-box2-text",
"type": "text",
"x": 460,
"y": 166,
"width": 400,
"height": 28,
"strokeColor": "#1e40af",
"backgroundColor": "transparent",
"fillStyle": "solid",
"strokeWidth": 1,
"strokeStyle": "solid",
"roughness": 0,
"opacity": 100,
"seed": 12024,
"version": 1,
"versionNonce": 12025,
"isDeleted": false,
"text": "Logical Clocks Solution (Lamport / Vector Clocks)",
"fontSize": 14,
"fontFamily": 5,
"textAlign": "center",
"verticalAlign": "middle",
"originalText": "Logical Clocks Solution (Lamport / Vector Clocks)"
},
{
"id": "lc-e1",
"type": "rectangle",
"x": 470,
"y": 90,
"width": 170,
"height": 50,
"strokeColor": "#10b981",
"backgroundColor": "#d1fae5",
"fillStyle": "solid",
"strokeWidth": 2,
"strokeStyle": "solid",
"roughness": 0,
"opacity": 100,
"roundness": {
"type": 3
},
"seed": 12026,
"version": 1,
"versionNonce": 12027,
"isDeleted": false,
"boundElements": [
{
"type": "text",
"id": "lc-e1-text"
}
]
},
{
"id": "lc-e1-text",
"type": "text",
"x": 480,
"y": 101,
"width": 150,
"height": 28,
"strokeColor": "#047857",
"backgroundColor": "transparent",
"fillStyle": "solid",
"strokeWidth": 1,
"strokeStyle": "solid",
"roughness": 0,
"opacity": 100,
"seed": 12028,
"version": 1,
"versionNonce": 12029,
"isDeleted": false,
"text": "Event 1 (Node A)\nLamport L=1, [A:1, B:0]",
"fontSize": 11,
"fontFamily": 5,
"textAlign": "center",
"verticalAlign": "middle",
"originalText": "Event 1 (Node A)\nLamport L=1, [A:1, B:0]",
"containerId": "lc-e1"
},
{
"id": "lc-a1",
"type": "arrow",
"x": 640,
"y": 115,
"width": 50,
"height": 0,
"strokeColor": "#2563eb",
"backgroundColor": "transparent",
"fillStyle": "solid",
"strokeWidth": 2,
"strokeStyle": "solid",
"roughness": 0,
"opacity": 100,
"points": [
[
0,
0
],
[
50,
0
]
],
"endArrowhead": "arrow",
"seed": 12030,
"version": 1,
"versionNonce": 12031,
"isDeleted": false
},
{
"id": "lc-e2",
"type": "rectangle",
"x": 690,
"y": 90,
"width": 160,
"height": 50,
"strokeColor": "#10b981",
"backgroundColor": "#d1fae5",
"fillStyle": "solid",
"strokeWidth": 2,
"strokeStyle": "solid",
"roughness": 0,
"opacity": 100,
"roundness": {
"type": 3
},
"seed": 12032,
"version": 1,
"versionNonce": 12033,
"isDeleted": false,
"boundElements": [
{
"type": "text",
"id": "lc-e2-text"
}
]
},
{
"id": "lc-e2-text",
"type": "text",
"x": 700,
"y": 101,
"width": 140,
"height": 28,
"strokeColor": "#047857",
"backgroundColor": "transparent",
"fillStyle": "solid",
"strokeWidth": 1,
"strokeStyle": "solid",
"roughness": 0,
"opacity": 100,
"seed": 12034,
"version": 1,
"versionNonce": 12035,
"isDeleted": false,
"text": "Event 2 (Node B)\nLamport L=2, [A:1, B:1]",
"fontSize": 11,
"fontFamily": 5,
"textAlign": "center",
"verticalAlign": "middle",
"originalText": "Event 2 (Node B)\nLamport L=2, [A:1, B:1]",
"containerId": "lc-e2"
},
{
"id": "lc-desc",
"type": "rectangle",
"x": 470,
"y": 160,
"width": 380,
"height": 140,
"strokeColor": "#2563eb",
"backgroundColor": "#dbeafe",
"fillStyle": "solid",
"strokeWidth": 2,
"strokeStyle": "solid",
"roughness": 0,
"opacity": 100,
"roundness": {
"type": 3
},
"seed": 12036,
"version": 1,
"versionNonce": 12037,
"isDeleted": false,
"boundElements": [
{
"type": "text",
"id": "lc-desc-text"
}
]
},
{
"id": "lc-desc-text",
"type": "text",
"x": 480,
"y": 209.375,
"width": 360,
"height": 41.25,
"strokeColor": "#1e40af",
"backgroundColor": "transparent",
"fillStyle": "solid",
"strokeWidth": 1,
"strokeStyle": "solid",
"roughness": 0,
"opacity": 100,
"seed": 12038,
"version": 1,
"versionNonce": 12039,
"isDeleted": false,
"text": "Logical Event Causality:\nEvents increment local logical counters.\nMessage payloads carry vector clock maps so receiving nodes advance clocks past the max seen counter.",
"fontSize": 11,
"fontFamily": 5,
"textAlign": "center",
"verticalAlign": "middle",
"originalText": "Logical Event Causality:\nEvents increment local logical counters.\nMessage payloads carry vector clock maps so receiving nodes advance clocks past the max seen counter.",
"containerId": "lc-desc"
}
]Clock Synchronization & Clock Drift
Physical quartz clocks on different server machines drift due to temperature variations. Protocols like NTP sync clocks within milliseconds, but physical timestamps cannot establish strict event causality.
Logical Clocks (Lamport Timestamps & Vector Clocks)
Logical clocks order events using monotonically increasing counter tuples passed along message payloads, determining 'happened-before' relationships without relying on physical wall clocks.
3. Leader Election & Consensus Algorithms (Paxos, Raft)
Distributed consensus is the fundamental problem of getting a group of independent nodes to agree on a single data value or state transition sequence.
Raft Consensus Protocol: Leader Election & Quorum Log Replication
System DesignTracing candidate election terms, AppendEntries RPC heartbeats, and majority quorum log commits
[
{
"id": "raft-box",
"type": "rectangle",
"x": 30,
"y": 40,
"width": 830,
"height": 280,
"strokeColor": "#10b981",
"backgroundColor": "#ecfdf5",
"fillStyle": "solid",
"strokeWidth": 2,
"strokeStyle": "solid",
"roughness": 0,
"opacity": 100,
"roundness": {
"type": 3
},
"seed": 12040,
"version": 1,
"versionNonce": 12041,
"isDeleted": false,
"boundElements": [
{
"type": "text",
"id": "raft-box-text"
}
]
},
{
"id": "raft-box-text",
"type": "text",
"x": 40,
"y": 166,
"width": 810,
"height": 28,
"strokeColor": "#047857",
"backgroundColor": "transparent",
"fillStyle": "solid",
"strokeWidth": 1,
"strokeStyle": "solid",
"roughness": 0,
"opacity": 100,
"seed": 12042,
"version": 1,
"versionNonce": 12043,
"isDeleted": false,
"text": "Raft Consensus Protocol (Leader Election & Log Replication)",
"fontSize": 14,
"fontFamily": 5,
"textAlign": "center",
"verticalAlign": "middle",
"originalText": "Raft Consensus Protocol (Leader Election & Log Replication)",
"containerId": "raft-box"
},
{
"id": "raft-leader",
"type": "rectangle",
"x": 350,
"y": 90,
"width": 190,
"height": 70,
"strokeColor": "#10b981",
"backgroundColor": "#d1fae5",
"fillStyle": "solid",
"strokeWidth": 2,
"strokeStyle": "solid",
"roughness": 0,
"opacity": 100,
"roundness": {
"type": 3
},
"seed": 12044,
"version": 1,
"versionNonce": 12045,
"isDeleted": false,
"boundElements": [
{
"type": "text",
"id": "raft-leader-text"
}
]
},
{
"id": "raft-leader-text",
"type": "text",
"x": 360,
"y": 102.5,
"width": 170,
"height": 45,
"strokeColor": "#047857",
"backgroundColor": "transparent",
"fillStyle": "solid",
"strokeWidth": 1,
"strokeStyle": "solid",
"roughness": 0,
"opacity": 100,
"seed": 12046,
"version": 1,
"versionNonce": 12047,
"isDeleted": false,
"text": "Leader Node (Term 2)\nAccepts Client Writes\nSends AppendEntries RPC",
"fontSize": 12,
"fontFamily": 5,
"textAlign": "center",
"verticalAlign": "middle",
"originalText": "Leader Node (Term 2)\nAccepts Client Writes\nSends AppendEntries RPC",
"containerId": "raft-leader"
},
{
"id": "r-a1",
"type": "arrow",
"x": 350,
"y": 125,
"width": -150,
"height": 75,
"strokeColor": "#10b981",
"backgroundColor": "transparent",
"fillStyle": "solid",
"strokeWidth": 2,
"strokeStyle": "solid",
"roughness": 0,
"opacity": 100,
"points": [
[
0,
0
],
[
-150,
75
]
],
"endArrowhead": "arrow",
"seed": 12048,
"version": 1,
"versionNonce": 12049,
"isDeleted": false
},
{
"id": "r-a2",
"type": "arrow",
"x": 540,
"y": 125,
"width": 140,
"height": 75,
"strokeColor": "#10b981",
"backgroundColor": "transparent",
"fillStyle": "solid",
"strokeWidth": 2,
"strokeStyle": "solid",
"roughness": 0,
"opacity": 100,
"points": [
[
0,
0
],
[
140,
75
]
],
"endArrowhead": "arrow",
"seed": 12050,
"version": 1,
"versionNonce": 12051,
"isDeleted": false
},
{
"id": "raft-f1",
"type": "rectangle",
"x": 70,
"y": 200,
"width": 220,
"height": 90,
"strokeColor": "#3b82f6",
"backgroundColor": "#dbeafe",
"fillStyle": "solid",
"strokeWidth": 2,
"strokeStyle": "solid",
"roughness": 0,
"opacity": 100,
"roundness": {
"type": 3
},
"seed": 12052,
"version": 1,
"versionNonce": 12053,
"isDeleted": false,
"boundElements": [
{
"type": "text",
"id": "raft-f1-text"
}
]
},
{
"id": "raft-f1-text",
"type": "text",
"x": 80,
"y": 224.375,
"width": 200,
"height": 41.25,
"strokeColor": "#1e40af",
"backgroundColor": "transparent",
"fillStyle": "solid",
"strokeWidth": 1,
"strokeStyle": "solid",
"roughness": 0,
"opacity": 100,
"seed": 12054,
"version": 1,
"versionNonce": 12055,
"isDeleted": false,
"text": "Follower Node 1\nLog: [Term1:X, Term2:Y]\nResponds ACK to Leader",
"fontSize": 11,
"fontFamily": 5,
"textAlign": "center",
"verticalAlign": "middle",
"originalText": "Follower Node 1\nLog: [Term1:X, Term2:Y]\nResponds ACK to Leader",
"containerId": "raft-f1"
},
{
"id": "raft-f2",
"type": "rectangle",
"x": 580,
"y": 200,
"width": 220,
"height": 90,
"strokeColor": "#3b82f6",
"backgroundColor": "#dbeafe",
"fillStyle": "solid",
"strokeWidth": 2,
"strokeStyle": "solid",
"roughness": 0,
"opacity": 100,
"roundness": {
"type": 3
},
"seed": 12056,
"version": 1,
"versionNonce": 12057,
"isDeleted": false,
"boundElements": [
{
"type": "text",
"id": "raft-f2-text"
}
]
},
{
"id": "raft-f2-text",
"type": "text",
"x": 590,
"y": 224.375,
"width": 200,
"height": 41.25,
"strokeColor": "#1e40af",
"backgroundColor": "transparent",
"fillStyle": "solid",
"strokeWidth": 1,
"strokeStyle": "solid",
"roughness": 0,
"opacity": 100,
"seed": 12058,
"version": 1,
"versionNonce": 12059,
"isDeleted": false,
"text": "Follower Node 2\nLog: [Term1:X, Term2:Y]\nResponds ACK to Leader",
"fontSize": 11,
"fontFamily": 5,
"textAlign": "center",
"verticalAlign": "middle",
"originalText": "Follower Node 2\nLog: [Term1:X, Term2:Y]\nResponds ACK to Leader",
"containerId": "raft-f2"
},
{
"id": "raft-quorum",
"type": "rectangle",
"x": 310,
"y": 195,
"width": 250,
"height": 90,
"strokeColor": "#8b4dde",
"backgroundColor": "#f3e8ff",
"fillStyle": "solid",
"strokeWidth": 2,
"strokeStyle": "solid",
"roughness": 0,
"opacity": 100,
"roundness": {
"type": 3
},
"seed": 12060,
"version": 1,
"versionNonce": 12061,
"isDeleted": false,
"boundElements": [
{
"type": "text",
"id": "raft-quorum-text"
}
]
},
{
"id": "raft-quorum-text",
"type": "text",
"x": 320,
"y": 219.375,
"width": 230,
"height": 41.25,
"strokeColor": "#6b21a8",
"backgroundColor": "transparent",
"fillStyle": "solid",
"strokeWidth": 1,
"strokeStyle": "solid",
"roughness": 0,
"opacity": 100,
"seed": 12062,
"version": 1,
"versionNonce": 12063,
"isDeleted": false,
"text": "Majority Quorum Commit:\n2 of 3 ACKs received.\nLeader commits entry to state machine.",
"fontSize": 11,
"fontFamily": 5,
"textAlign": "center",
"verticalAlign": "middle",
"originalText": "Majority Quorum Commit:\n2 of 3 ACKs received.\nLeader commits entry to state machine.",
"containerId": "raft-quorum"
}
]Raft Consensus Algorithm
Decomposes consensus into Leader Election, Log Replication, and Safety. Raft uses randomized election timeouts to ensure single candidates win elections rapidly.
Paxos Consensus Algorithm
The classic consensus protocol using Two-Phase rounds (Prepare/Promise and Accept/Accepted) to reach agreement despite node crashes and message delays.
Examine the Raft leader election state machine simulation below to see randomized timeouts and vote requests in action.
Raft Consensus Leader Election Simulation
Implementing candidate term increments, randomized election timers, and majority quorum vote checks
Press Run to execute the code and see output here.
4. Distributed Locking & Commit Protocols (2PC vs 3PC)
Atomic transaction processing across multiple distinct database nodes requires structured commit protocols and distributed mutex locks.
Two-Phase Commit (2PC) vs Three-Phase Commit (3PC) Protocol Flow
System DesignComparing blocking coordinator 2PC prepare/commit phases against non-blocking 3PC PreCommit states
[
{
"id": "pc2-box",
"type": "rectangle",
"x": 30,
"y": 40,
"width": 400,
"height": 280,
"strokeColor": "#d97706",
"backgroundColor": "#fffbe6",
"fillStyle": "solid",
"strokeWidth": 2,
"strokeStyle": "solid",
"roughness": 0,
"opacity": 100,
"roundness": {
"type": 3
},
"seed": 12064,
"version": 1,
"versionNonce": 12065,
"isDeleted": false
},
{
"id": "pc2-box-text",
"type": "text",
"x": 60,
"y": 191,
"width": 340,
"height": 28,
"strokeColor": "#92400e",
"backgroundColor": "transparent",
"fillStyle": "solid",
"strokeWidth": 1,
"strokeStyle": "solid",
"roughness": 0,
"opacity": 100,
"seed": 12066,
"version": 1,
"versionNonce": 12067,
"isDeleted": false,
"text": "Two-Phase Commit (2PC)",
"fontSize": 14,
"fontFamily": 5,
"textAlign": "center",
"verticalAlign": "middle",
"originalText": "Two-Phase Commit (2PC)",
"containerId": "pc2-commit"
},
{
"id": "pc2-coord",
"type": "rectangle",
"x": 50,
"y": 90,
"width": 360,
"height": 50,
"strokeColor": "#f59e0b",
"backgroundColor": "#fef3c7",
"fillStyle": "solid",
"strokeWidth": 2,
"strokeStyle": "solid",
"roughness": 0,
"opacity": 100,
"roundness": {
"type": 3
},
"seed": 12068,
"version": 1,
"versionNonce": 12069,
"isDeleted": false,
"boundElements": [
{
"type": "text",
"id": "pc2-coord-text"
}
]
},
{
"id": "pc2-coord-text",
"type": "text",
"x": 60,
"y": 101,
"width": 340,
"height": 28,
"strokeColor": "#b45309",
"backgroundColor": "transparent",
"fillStyle": "solid",
"strokeWidth": 1,
"strokeStyle": "solid",
"roughness": 0,
"opacity": 100,
"seed": 12070,
"version": 1,
"versionNonce": 12071,
"isDeleted": false,
"text": "Phase 1: Coordinator sends PREPARE to all nodes",
"fontSize": 11,
"fontFamily": 5,
"textAlign": "center",
"verticalAlign": "middle",
"originalText": "Phase 1: Coordinator sends PREPARE to all nodes",
"containerId": "pc2-coord"
},
{
"id": "pc2-a1",
"type": "arrow",
"x": 230,
"y": 140,
"width": 0,
"height": 40,
"strokeColor": "#d97706",
"backgroundColor": "transparent",
"fillStyle": "solid",
"strokeWidth": 2,
"strokeStyle": "solid",
"roughness": 0,
"opacity": 100,
"points": [
[
0,
0
],
[
0,
40
]
],
"endArrowhead": "arrow",
"seed": 12072,
"version": 1,
"versionNonce": 12073,
"isDeleted": false
},
{
"id": "pc2-commit",
"type": "rectangle",
"x": 50,
"y": 180,
"width": 360,
"height": 50,
"strokeColor": "#f59e0b",
"backgroundColor": "#fef3c7",
"fillStyle": "solid",
"strokeWidth": 2,
"strokeStyle": "solid",
"roughness": 0,
"opacity": 100,
"roundness": {
"type": 3
},
"seed": 12074,
"version": 1,
"versionNonce": 12075,
"isDeleted": false,
"boundElements": [
{
"type": "text",
"id": "pc2-box-text"
},
{
"type": "text",
"id": "pc2-commit-text"
}
]
},
{
"id": "pc2-commit-text",
"type": "text",
"x": 60,
"y": 191,
"width": 340,
"height": 28,
"strokeColor": "#b45309",
"backgroundColor": "transparent",
"fillStyle": "solid",
"strokeWidth": 1,
"strokeStyle": "solid",
"roughness": 0,
"opacity": 100,
"seed": 12076,
"version": 1,
"versionNonce": 12077,
"isDeleted": false,
"text": "Phase 2: If all VOTE YES -> Coordinator sends COMMIT",
"fontSize": 11,
"fontFamily": 5,
"textAlign": "center",
"verticalAlign": "middle",
"originalText": "Phase 2: If all VOTE YES -> Coordinator sends COMMIT",
"containerId": "pc2-commit"
},
{
"id": "pc2-flaw",
"type": "rectangle",
"x": 50,
"y": 245,
"width": 360,
"height": 60,
"strokeColor": "#ef4444",
"backgroundColor": "#fef2f2",
"fillStyle": "solid",
"strokeWidth": 2,
"strokeStyle": "solid",
"roughness": 0,
"opacity": 100,
"roundness": {
"type": 3
},
"seed": 12078,
"version": 1,
"versionNonce": 12079,
"isDeleted": false,
"boundElements": [
{
"type": "text",
"id": "pc2-flaw-text"
}
]
},
{
"id": "pc2-flaw-text",
"type": "text",
"x": 60,
"y": 261,
"width": 340,
"height": 28,
"strokeColor": "#991b1b",
"backgroundColor": "transparent",
"fillStyle": "solid",
"strokeWidth": 1,
"strokeStyle": "solid",
"roughness": 0,
"opacity": 100,
"seed": 12080,
"version": 1,
"versionNonce": 12081,
"isDeleted": false,
"text": "Flaw: If Coordinator crashes during Phase 2, participants block holding locks indefinitely!",
"fontSize": 10,
"fontFamily": 5,
"textAlign": "center",
"verticalAlign": "middle",
"originalText": "Flaw: If Coordinator crashes during Phase 2, participants block holding locks indefinitely!",
"containerId": "pc2-flaw"
},
{
"id": "pc3-box",
"type": "rectangle",
"x": 450,
"y": 40,
"width": 420,
"height": 280,
"strokeColor": "#2563eb",
"backgroundColor": "#eff6ff",
"fillStyle": "solid",
"strokeWidth": 2,
"strokeStyle": "solid",
"roughness": 0,
"opacity": 100,
"roundness": {
"type": 3
},
"seed": 12082,
"version": 1,
"versionNonce": 12083,
"isDeleted": false
},
{
"id": "pc3-box-text",
"type": "text",
"x": 480,
"y": 158.5,
"width": 360,
"height": 28,
"strokeColor": "#1e40af",
"backgroundColor": "transparent",
"fillStyle": "solid",
"strokeWidth": 1,
"strokeStyle": "solid",
"roughness": 0,
"opacity": 100,
"seed": 12084,
"version": 1,
"versionNonce": 12085,
"isDeleted": false,
"text": "Three-Phase Commit (3PC - Non-Blocking)",
"fontSize": 14,
"fontFamily": 5,
"textAlign": "center",
"verticalAlign": "middle",
"originalText": "Three-Phase Commit (3PC - Non-Blocking)",
"containerId": "pc3-p2"
},
{
"id": "pc3-p1",
"type": "rectangle",
"x": 470,
"y": 85,
"width": 380,
"height": 45,
"strokeColor": "#3b82f6",
"backgroundColor": "#dbeafe",
"fillStyle": "solid",
"strokeWidth": 2,
"strokeStyle": "solid",
"roughness": 0,
"opacity": 100,
"roundness": {
"type": 3
},
"seed": 12086,
"version": 1,
"versionNonce": 12087,
"isDeleted": false,
"boundElements": [
{
"type": "text",
"id": "pc3-p1-text"
}
]
},
{
"id": "pc3-p1-text",
"type": "text",
"x": 480,
"y": 93.5,
"width": 360,
"height": 28,
"strokeColor": "#1e40af",
"backgroundColor": "transparent",
"fillStyle": "solid",
"strokeWidth": 1,
"strokeStyle": "solid",
"roughness": 0,
"opacity": 100,
"seed": 12088,
"version": 1,
"versionNonce": 12089,
"isDeleted": false,
"text": "Phase 1: CanCommit? (Check readiness)",
"fontSize": 11,
"fontFamily": 5,
"textAlign": "center",
"verticalAlign": "middle",
"originalText": "Phase 1: CanCommit? (Check readiness)",
"containerId": "pc3-p1"
},
{
"id": "pc3-a1",
"type": "arrow",
"x": 660,
"y": 130,
"width": 0,
"height": 20,
"strokeColor": "#2563eb",
"backgroundColor": "transparent",
"fillStyle": "solid",
"strokeWidth": 2,
"strokeStyle": "solid",
"roughness": 0,
"opacity": 100,
"points": [
[
0,
0
],
[
0,
20
]
],
"endArrowhead": "arrow",
"seed": 12090,
"version": 1,
"versionNonce": 12091,
"isDeleted": false
},
{
"id": "pc3-p2",
"type": "rectangle",
"x": 470,
"y": 150,
"width": 380,
"height": 45,
"strokeColor": "#3b82f6",
"backgroundColor": "#dbeafe",
"fillStyle": "solid",
"strokeWidth": 2,
"strokeStyle": "solid",
"roughness": 0,
"opacity": 100,
"roundness": {
"type": 3
},
"seed": 12092,
"version": 1,
"versionNonce": 12093,
"isDeleted": false,
"boundElements": [
{
"type": "text",
"id": "pc3-box-text"
},
{
"type": "text",
"id": "pc3-p2-text"
}
]
},
{
"id": "pc3-p2-text",
"type": "text",
"x": 480,
"y": 158.5,
"width": 360,
"height": 28,
"strokeColor": "#1e40af",
"backgroundColor": "transparent",
"fillStyle": "solid",
"strokeWidth": 1,
"strokeStyle": "solid",
"roughness": 0,
"opacity": 100,
"seed": 12094,
"version": 1,
"versionNonce": 12095,
"isDeleted": false,
"text": "Phase 2: PreCommit (Acknowledge state lock)",
"fontSize": 11,
"fontFamily": 5,
"textAlign": "center",
"verticalAlign": "middle",
"originalText": "Phase 2: PreCommit (Acknowledge state lock)",
"containerId": "pc3-p2"
},
{
"id": "pc3-a2",
"type": "arrow",
"x": 660,
"y": 195,
"width": 0,
"height": 20,
"strokeColor": "#2563eb",
"backgroundColor": "transparent",
"fillStyle": "solid",
"strokeWidth": 2,
"strokeStyle": "solid",
"roughness": 0,
"opacity": 100,
"points": [
[
0,
0
],
[
0,
20
]
],
"endArrowhead": "arrow",
"seed": 12096,
"version": 1,
"versionNonce": 12097,
"isDeleted": false
},
{
"id": "pc3-p3",
"type": "rectangle",
"x": 470,
"y": 215,
"width": 380,
"height": 45,
"strokeColor": "#3b82f6",
"backgroundColor": "#dbeafe",
"fillStyle": "solid",
"strokeWidth": 2,
"strokeStyle": "solid",
"roughness": 0,
"opacity": 100,
"roundness": {
"type": 3
},
"seed": 12098,
"version": 1,
"versionNonce": 12099,
"isDeleted": false,
"boundElements": [
{
"type": "text",
"id": "pc3-p3-text"
}
]
},
{
"id": "pc3-p3-text",
"type": "text",
"x": 480,
"y": 223.5,
"width": 360,
"height": 28,
"strokeColor": "#1e40af",
"backgroundColor": "transparent",
"fillStyle": "solid",
"strokeWidth": 1,
"strokeStyle": "solid",
"roughness": 0,
"opacity": 100,
"seed": 12100,
"version": 1,
"versionNonce": 12101,
"isDeleted": false,
"text": "Phase 3: DoCommit (Final execution)",
"fontSize": 11,
"fontFamily": 5,
"textAlign": "center",
"verticalAlign": "middle",
"originalText": "Phase 3: DoCommit (Final execution)",
"containerId": "pc3-p3"
},
{
"id": "pc3-adv",
"type": "rectangle",
"x": 470,
"y": 268,
"width": 380,
"height": 40,
"strokeColor": "#10b981",
"backgroundColor": "#ecfdf5",
"fillStyle": "solid",
"strokeWidth": 2,
"strokeStyle": "solid",
"roughness": 0,
"opacity": 100,
"roundness": {
"type": 3
},
"seed": 12102,
"version": 1,
"versionNonce": 12103,
"isDeleted": false,
"boundElements": [
{
"type": "text",
"id": "pc3-adv-text"
}
]
},
{
"id": "pc3-adv-text",
"type": "text",
"x": 480,
"y": 274,
"width": 360,
"height": 28,
"strokeColor": "#047857",
"backgroundColor": "transparent",
"fillStyle": "solid",
"strokeWidth": 1,
"strokeStyle": "solid",
"roughness": 0,
"opacity": 100,
"seed": 12104,
"version": 1,
"versionNonce": 12105,
"isDeleted": false,
"text": "Advantage: PreCommit state allows timeout auto-abort.",
"fontSize": 10,
"fontFamily": 5,
"textAlign": "center",
"verticalAlign": "middle",
"originalText": "Advantage: PreCommit state allows timeout auto-abort.",
"containerId": "pc3-adv"
}
]Two-Phase Commit (2PC)
Phase 1 (Prepare): Coordinator asks all nodes if they are ready to commit. Phase 2 (Commit): If all vote YES, coordinator sends COMMIT. If the coordinator crashes during Phase 2, nodes block holding locks.
Three-Phase Commit (3PC)
Adds a non-blocking PreCommit phase between Prepare and Commit. Allows participants to time out and safely abort if the coordinator disappears.
Distributed Locks (Redlock & Fencing Tokens)
Acquires mutex locks across distributed Redis nodes using atomic leases. Includes monotonically increasing fencing tokens to reject stale writes from delayed processes.
Review the Node.js Distributed Lock engine below demonstrating Redis atomic key leases and atomic Lua release scripts.
Distributed Lock Engine (Redlock Pattern & Fencing Tokens)
Acquiring atomic leases with Redis SET NX PX and releasing ownership using atomic Lua scripts
Press Run to execute the code and see output here.
5. Gossip Protocol, Split-Brain & Byzantine Fault Tolerance
Decentralized cluster management requires peer-to-peer state propagation algorithms and partition protection mechanisms.
Gossip Protocol Dissemination & Split-Brain Quorum Partitioning
System DesignVisualizing O(log N) peer gossip state dissemination and majority quorum split-brain protection
[
{
"id": "gossip-box",
"type": "rectangle",
"x": 30,
"y": 40,
"width": 400,
"height": 280,
"strokeColor": "#8b4dde",
"backgroundColor": "#f3e8ff",
"fillStyle": "solid",
"strokeWidth": 2,
"strokeStyle": "solid",
"roughness": 0,
"opacity": 100,
"roundness": {
"type": 3
},
"seed": 12106,
"version": 1,
"versionNonce": 12107,
"isDeleted": false
},
{
"id": "gossip-box-text",
"type": "text",
"x": 210,
"y": 153.5,
"width": 70,
"height": 28,
"strokeColor": "#6b21a8",
"backgroundColor": "transparent",
"fillStyle": "solid",
"strokeWidth": 1,
"strokeStyle": "solid",
"roughness": 0,
"opacity": 100,
"seed": 12108,
"version": 1,
"versionNonce": 12109,
"isDeleted": false,
"text": "Gossip Protocol (Epidemic Dissemination)",
"fontSize": 14,
"fontFamily": 5,
"textAlign": "center",
"verticalAlign": "middle",
"originalText": "Gossip Protocol (Epidemic Dissemination)",
"containerId": "g-n3"
},
{
"id": "g-n1",
"type": "rectangle",
"x": 50,
"y": 90,
"width": 100,
"height": 50,
"strokeColor": "#a855f7",
"backgroundColor": "#f3e8ff",
"fillStyle": "solid",
"strokeWidth": 2,
"strokeStyle": "solid",
"roughness": 0,
"opacity": 100,
"roundness": {
"type": 3
},
"seed": 12110,
"version": 1,
"versionNonce": 12111,
"isDeleted": false,
"boundElements": [
{
"type": "text",
"id": "g-n1-text"
}
]
},
{
"id": "g-n1-text",
"type": "text",
"x": 60,
"y": 101,
"width": 80,
"height": 28,
"strokeColor": "#6b21a8",
"backgroundColor": "transparent",
"fillStyle": "solid",
"strokeWidth": 1,
"strokeStyle": "solid",
"roughness": 0,
"opacity": 100,
"seed": 12112,
"version": 1,
"versionNonce": 12113,
"isDeleted": false,
"text": "Node 1\n(State Update)",
"fontSize": 11,
"fontFamily": 5,
"textAlign": "center",
"verticalAlign": "middle",
"originalText": "Node 1\n(State Update)",
"containerId": "g-n1"
},
{
"id": "g-a1",
"type": "arrow",
"x": 150,
"y": 115,
"width": 50,
"height": -15,
"strokeColor": "#8b4dde",
"backgroundColor": "transparent",
"fillStyle": "solid",
"strokeWidth": 2,
"strokeStyle": "solid",
"roughness": 0,
"opacity": 100,
"points": [
[
0,
0
],
[
50,
-15
]
],
"endArrowhead": "arrow",
"seed": 12114,
"version": 1,
"versionNonce": 12115,
"isDeleted": false
},
{
"id": "g-a2",
"type": "arrow",
"x": 150,
"y": 115,
"width": 50,
"height": 45,
"strokeColor": "#8b4dde",
"backgroundColor": "transparent",
"fillStyle": "solid",
"strokeWidth": 2,
"strokeStyle": "solid",
"roughness": 0,
"opacity": 100,
"points": [
[
0,
0
],
[
50,
45
]
],
"endArrowhead": "arrow",
"seed": 12116,
"version": 1,
"versionNonce": 12117,
"isDeleted": false
},
{
"id": "g-n2",
"type": "rectangle",
"x": 200,
"y": 80,
"width": 90,
"height": 45,
"strokeColor": "#a855f7",
"backgroundColor": "#e9d5ff",
"fillStyle": "solid",
"strokeWidth": 2,
"strokeStyle": "solid",
"roughness": 0,
"opacity": 100,
"roundness": {
"type": 3
},
"seed": 12118,
"version": 1,
"versionNonce": 12119,
"isDeleted": false,
"boundElements": [
{
"type": "text",
"id": "g-n2-text"
}
]
},
{
"id": "g-n2-text",
"type": "text",
"x": 210,
"y": 88.5,
"width": 70,
"height": 28,
"strokeColor": "#6b21a8",
"backgroundColor": "transparent",
"fillStyle": "solid",
"strokeWidth": 1,
"strokeStyle": "solid",
"roughness": 0,
"opacity": 100,
"seed": 12120,
"version": 1,
"versionNonce": 12121,
"isDeleted": false,
"text": "Node 2",
"fontSize": 11,
"fontFamily": 5,
"textAlign": "center",
"verticalAlign": "middle",
"originalText": "Node 2",
"containerId": "g-n2"
},
{
"id": "g-n3",
"type": "rectangle",
"x": 200,
"y": 145,
"width": 90,
"height": 45,
"strokeColor": "#a855f7",
"backgroundColor": "#e9d5ff",
"fillStyle": "solid",
"strokeWidth": 2,
"strokeStyle": "solid",
"roughness": 0,
"opacity": 100,
"roundness": {
"type": 3
},
"seed": 12122,
"version": 1,
"versionNonce": 12123,
"isDeleted": false,
"boundElements": [
{
"type": "text",
"id": "gossip-box-text"
},
{
"type": "text",
"id": "g-n3-text"
}
]
},
{
"id": "g-n3-text",
"type": "text",
"x": 210,
"y": 153.5,
"width": 70,
"height": 28,
"strokeColor": "#6b21a8",
"backgroundColor": "transparent",
"fillStyle": "solid",
"strokeWidth": 1,
"strokeStyle": "solid",
"roughness": 0,
"opacity": 100,
"seed": 12124,
"version": 1,
"versionNonce": 12125,
"isDeleted": false,
"text": "Node 3",
"fontSize": 11,
"fontFamily": 5,
"textAlign": "center",
"verticalAlign": "middle",
"originalText": "Node 3",
"containerId": "g-n3"
},
{
"id": "g-a3",
"type": "arrow",
"x": 290,
"y": 100,
"width": 30,
"height": 40,
"strokeColor": "#8b4dde",
"backgroundColor": "transparent",
"fillStyle": "solid",
"strokeWidth": 2,
"strokeStyle": "solid",
"roughness": 0,
"opacity": 100,
"points": [
[
0,
0
],
[
30,
40
]
],
"endArrowhead": "arrow",
"seed": 12126,
"version": 1,
"versionNonce": 12127,
"isDeleted": false
},
{
"id": "g-a4",
"type": "arrow",
"x": 290,
"y": 165,
"width": 30,
"height": -15,
"strokeColor": "#8b4dde",
"backgroundColor": "transparent",
"fillStyle": "solid",
"strokeWidth": 2,
"strokeStyle": "solid",
"roughness": 0,
"opacity": 100,
"points": [
[
0,
0
],
[
30,
-15
]
],
"endArrowhead": "arrow",
"seed": 12128,
"version": 1,
"versionNonce": 12129,
"isDeleted": false
},
{
"id": "g-n4",
"type": "rectangle",
"x": 320,
"y": 125,
"width": 90,
"height": 45,
"strokeColor": "#a855f7",
"backgroundColor": "#e9d5ff",
"fillStyle": "solid",
"strokeWidth": 2,
"strokeStyle": "solid",
"roughness": 0,
"opacity": 100,
"roundness": {
"type": 3
},
"seed": 12130,
"version": 1,
"versionNonce": 12131,
"isDeleted": false,
"boundElements": [
{
"type": "text",
"id": "g-n4-text"
}
]
},
{
"id": "g-n4-text",
"type": "text",
"x": 330,
"y": 133.5,
"width": 70,
"height": 28,
"strokeColor": "#6b21a8",
"backgroundColor": "transparent",
"fillStyle": "solid",
"strokeWidth": 1,
"strokeStyle": "solid",
"roughness": 0,
"opacity": 100,
"seed": 12132,
"version": 1,
"versionNonce": 12133,
"isDeleted": false,
"text": "Node 4",
"fontSize": 11,
"fontFamily": 5,
"textAlign": "center",
"verticalAlign": "middle",
"originalText": "Node 4",
"containerId": "g-n4"
},
{
"id": "g-desc",
"type": "rectangle",
"x": 50,
"y": 205,
"width": 360,
"height": 100,
"strokeColor": "#8b4dde",
"backgroundColor": "#f3e8ff",
"fillStyle": "solid",
"strokeWidth": 2,
"strokeStyle": "solid",
"roughness": 0,
"opacity": 100,
"roundness": {
"type": 3
},
"seed": 12134,
"version": 1,
"versionNonce": 12135,
"isDeleted": false,
"boundElements": [
{
"type": "text",
"id": "g-desc-text"
}
]
},
{
"id": "g-desc-text",
"type": "text",
"x": 60,
"y": 234.375,
"width": 340,
"height": 41.25,
"strokeColor": "#6b21a8",
"backgroundColor": "transparent",
"fillStyle": "solid",
"strokeWidth": 1,
"strokeStyle": "solid",
"roughness": 0,
"opacity": 100,
"seed": 12136,
"version": 1,
"versionNonce": 12137,
"isDeleted": false,
"text": "Peer-to-Peer Gossip:\nNodes periodically exchange state with k random peers.\nAchieves cluster-wide convergence in O(log N) rounds.",
"fontSize": 11,
"fontFamily": 5,
"textAlign": "center",
"verticalAlign": "middle",
"originalText": "Peer-to-Peer Gossip:\nNodes periodically exchange state with k random peers.\nAchieves cluster-wide convergence in O(log N) rounds.",
"containerId": "g-desc"
},
{
"id": "sb-box",
"type": "rectangle",
"x": 450,
"y": 40,
"width": 420,
"height": 280,
"strokeColor": "#ef4444",
"backgroundColor": "#fef2f2",
"fillStyle": "solid",
"strokeWidth": 2,
"strokeStyle": "solid",
"roughness": 0,
"opacity": 100,
"roundness": {
"type": 3
},
"seed": 12138,
"version": 1,
"versionNonce": 12139,
"isDeleted": false,
"boundElements": [
{
"type": "text",
"id": "sb-box-text"
}
]
},
{
"id": "sb-box-text",
"type": "text",
"x": 460,
"y": 166,
"width": 400,
"height": 28,
"strokeColor": "#991b1b",
"backgroundColor": "transparent",
"fillStyle": "solid",
"strokeWidth": 1,
"strokeStyle": "solid",
"roughness": 0,
"opacity": 100,
"seed": 12140,
"version": 1,
"versionNonce": 12141,
"isDeleted": false,
"text": "Split-Brain & Quorum Fencing",
"fontSize": 14,
"fontFamily": 5,
"textAlign": "center",
"verticalAlign": "middle",
"originalText": "Split-Brain & Quorum Fencing",
"containerId": "sb-box"
},
{
"id": "sb-part1",
"type": "rectangle",
"x": 470,
"y": 90,
"width": 180,
"height": 100,
"strokeColor": "#10b981",
"backgroundColor": "#ecfdf5",
"fillStyle": "solid",
"strokeWidth": 2,
"strokeStyle": "solid",
"roughness": 0,
"opacity": 100,
"roundness": {
"type": 3
},
"seed": 12142,
"version": 1,
"versionNonce": 12143,
"isDeleted": false,
"boundElements": [
{
"type": "text",
"id": "sb-part1-text"
}
]
},
{
"id": "sb-part1-text",
"type": "text",
"x": 480,
"y": 119.375,
"width": 160,
"height": 41.25,
"strokeColor": "#047857",
"backgroundColor": "transparent",
"fillStyle": "solid",
"strokeWidth": 1,
"strokeStyle": "solid",
"roughness": 0,
"opacity": 100,
"seed": 12144,
"version": 1,
"versionNonce": 12145,
"isDeleted": false,
"text": "Partition A (3 Nodes)\nMajority Quorum (3/5)\nSTATUS: ACTIVE LEADER",
"fontSize": 11,
"fontFamily": 5,
"textAlign": "center",
"verticalAlign": "middle",
"originalText": "Partition A (3 Nodes)\nMajority Quorum (3/5)\nSTATUS: ACTIVE LEADER",
"containerId": "sb-part1"
},
{
"id": "sb-part2",
"type": "rectangle",
"x": 670,
"y": 90,
"width": 180,
"height": 100,
"strokeColor": "#ef4444",
"backgroundColor": "#fee2e2",
"fillStyle": "solid",
"strokeWidth": 2,
"strokeStyle": "solid",
"roughness": 0,
"opacity": 100,
"roundness": {
"type": 3
},
"seed": 12146,
"version": 1,
"versionNonce": 12147,
"isDeleted": false,
"boundElements": [
{
"type": "text",
"id": "sb-part2-text"
}
]
},
{
"id": "sb-part2-text",
"type": "text",
"x": 680,
"y": 119.375,
"width": 160,
"height": 41.25,
"strokeColor": "#991b1b",
"backgroundColor": "transparent",
"fillStyle": "solid",
"strokeWidth": 1,
"strokeStyle": "solid",
"roughness": 0,
"opacity": 100,
"seed": 12148,
"version": 1,
"versionNonce": 12149,
"isDeleted": false,
"text": "Partition B (2 Nodes)\nMinority (2/5 < Quorum)\nSTATUS: STEP DOWN",
"fontSize": 11,
"fontFamily": 5,
"textAlign": "center",
"verticalAlign": "middle",
"originalText": "Partition B (2 Nodes)\nMinority (2/5 < Quorum)\nSTATUS: STEP DOWN",
"containerId": "sb-part2"
},
{
"id": "sb-fence",
"type": "rectangle",
"x": 470,
"y": 205,
"width": 380,
"height": 100,
"strokeColor": "#2563eb",
"backgroundColor": "#eff6ff",
"fillStyle": "solid",
"strokeWidth": 2,
"strokeStyle": "solid",
"roughness": 0,
"opacity": 100,
"roundness": {
"type": 3
},
"seed": 12150,
"version": 1,
"versionNonce": 12151,
"isDeleted": false,
"boundElements": [
{
"type": "text",
"id": "sb-fence-text"
}
]
},
{
"id": "sb-fence-text",
"type": "text",
"x": 480,
"y": 241,
"width": 360,
"height": 28,
"strokeColor": "#1e40af",
"backgroundColor": "transparent",
"fillStyle": "solid",
"strokeWidth": 1,
"strokeStyle": "solid",
"roughness": 0,
"opacity": 100,
"seed": 12152,
"version": 1,
"versionNonce": 12153,
"isDeleted": false,
"text": "Fencing Tokens Mitigation:\nMonotonically increasing fencing tokens (Epoch 12) reject writes with stale tokens (Epoch 11).",
"fontSize": 11,
"fontFamily": 5,
"textAlign": "center",
"verticalAlign": "middle",
"originalText": "Fencing Tokens Mitigation:\nMonotonically increasing fencing tokens (Epoch 12) reject writes with stale tokens (Epoch 11).",
"containerId": "sb-fence"
}
]Gossip Protocol (Epidemic Dissemination)
Nodes periodically pick random peers to exchange cluster membership state. Spreads state changes across thousands of nodes in logarithmic O(log N) time with zero single point of failure.
Split-Brain Problem & Quorum Fencing
Occurs when a network partition cuts a cluster in half, causing nodes on both sides to elect separate leaders. Prevented by requiring a Majority Quorum (N/2 + 1) for write authorization.
Byzantine Fault Tolerance (BFT)
Addresses scenarios where nodes can not only fail or crash, but also send corrupt or malicious data (e.g. blockchain networks). Reaches consensus if over 2/3 of nodes are honest (3f + 1 total nodes required to tolerate f faulty nodes).
Distributed Systems Fundamentals Knowledge Verification
1. What defines a distributed system?
2. Why are physical wall-clock timestamps unreliable in distributed systems?
3. How does the Raft consensus algorithm select a new leader node?
4. What is the main drawback of the Two-Phase Commit (2PC) protocol?
5. What is the Split-Brain problem in distributed clusters?