Architecture

📖 2 min read 📄 Part 3 of 10

Distributed Locking System - System Architecture

High-Level Architecture Overview

System Architecture Principles

  • Consensus-Based: Raft/Paxos for state replication
  • Leader-Based Writes: Single leader for all writes
  • Quorum Reads: Majority reads for consistency
  • Session-Based: Client sessions with heartbeats
  • Watch-Based Notifications: Event-driven updates
  • Fault Tolerant: Survive minority node failures

Core Architecture Components

CLIENT APPLICATIONS 🖥️ Microservices, Distributed Systems, Databases LOCK CLIENT LIBRARIES 🔑 Lock Client 1 🔑 Lock Client 2 🔑 Lock Client 3 ⚖️ Client-Side Load Balancer CONSENSUS CLUSTER 👑 Leader Node 1 Handles all writes 🎫 Fencing Tokens 📋 Follower Node 2 Replicates state 📋 Follower Node 3 Replicates state 📋 Node N Follower 🧭 Raft Consensus — Log Replication 💾 Persistent Store (RocksDB / LevelDB) Lock State • TTL Management • Session Data
Distributed Locking — Consensus-Based Architecture

Raft Consensus Algorithm

Raft Overview

Raft Components:
1. Leader Election
2. Log Replication
3. Safety Guarantees

Node States:
- Leader: Handles all writes, replicates to followers
- Follower: Receives log entries, votes in elections
- Candidate: Requests votes during election

Terms:
- Monotonically increasing election term
- Each term has at most one leader
- Used to detect stale information