Design a high-level system that allows multiple master nodes to handle read and write operations concurrently, while ensuring strong consistency across all nodes. The system should handle conflicts, ensure fault tolerance, and scale efficiently.
Functional Requirements (FR)
Concurrent Writes
•Multiple master nodes can accept write requests simultaneously.
•All writes must be propagated to other master nodes to maintain a consistent state.
Read Operations
•Reads can be served from any master node.
•Reads must reflect the latest committed writes (strong consistency).
Conflict Detection & Resolution
•Detect conflicting writes from different masters.
•Resolve conflicts deterministically using version vectors, timestamps, or application-defined rules.
Replication
•Synchronously replicate updates across all masters for strong consistency.
Fault Tolerance
•Handle node failures without data loss.
•Ensure high availability and automatic recovery of failed nodes.
Optional: Transaction Support
•Support distributed ACID transactions across multiple masters.
Non-Functional Requirements (NFR)
•Strong Consistency: All nodes reflect the same state after each write.
•High Availability: System should remain operational despite master node failures.
•Durability: No committed write should be lost.
•Scalability: Support increasing numbers of nodes and clients.
•Low Latency: Minimize write propagation and conflict resolution delays.
Core Components
API / Application Layer
•Handles client read/write requests.
•Routes requests to master nodes.
Master Nodes
•Each node can process reads and writes.
•Maintains a local copy of the database.
•Propagates changes to other masters.
Replication Service
•Ensures that updates from one master are propagated to all other masters.
•Use synchronous replication for strong consistency.
Conflict Resolution Module
•Detects conflicting writes using timestamps, version vectors, or consensus protocols.
•Resolves conflicts to maintain deterministic state across nodes.
Consensus / Coordination Service
•Optional: Use Paxos or Raft for leaderless coordination and ensuring agreement among masters.
Failure Detection & Recovery
•Monitors master health and triggers re-sync of data for recovering nodes.
Storage Layer
•Persistent storage with write-ahead logs for durability and crash recovery.
High-Level Data Flow
1.Client issues a write → API Layer → Master Node → Local update → Replicate to all other masters → Commit after replication acknowledgment.
2.Client issues a read → API Layer → Any Master Node → Return the latest committed value.
3.Conflict occurs → Conflict Resolution Module → Resolve and propagate resolved state → Update all masters.
4.Node failure → Failure Detection → Recover missing updates from healthy masters → Restore consistency.
Design Considerations
•Synchronous vs Asynchronous Replication: Synchronous replication ensures strong consistency but adds latency.
•Conflict Resolution: Deterministic strategies like last-write-wins or version vectors.
•Partitioning / Sharding: Distribute data across masters to improve scalability.
•Monitoring & Alerts: Track replication lag, conflicts, and node health.
•Performance Optimization: Batch writes, pipeline replication, or use quorum-based commits to reduce latency.
✅ This HLD outlines a multi-master system with strong consistency, including core modules, data flow, replication, conflict resolution, and fault tolerance considerations.