Scale a NoSQL Key–Value Store to One Million QPS
LinkedInSoftware Engineer · OnsiteLast updated
Design a distributed, highly available NoSQL key-value store capable of serving 1M QPS across 50 million key-value pairs with low p99 latency.
Scenario
LinkedIn maintains critical user context, service state, and real-time counter data across distributed microservices. You are tasked with designing a distributed NoSQL key-value store capable of handling high-throughput, low-latency lookups and updates at scale.
Requirements
Functional Requirements
get(key): Retrieve the value associated with the specified key.put(key, value): Insert or update the value for the given key.delete(key): Remove the key-value pair.
Non-Functional Requirements
- High Throughput: Support 1,000,000 queries per second (QPS) at peak.
- Low Latency: p99 latency under 5 ms for reads and under 10 ms for writes.
- High Availability: 99.999% uptime; tolerate individual node and rack failures.
- Tunable Consistency: Support trade-offs between eventual consistency and strong consistency depending on client requirements.
- Durability: Data must not be lost once a write is acknowledged.
Scale & Capacity Assumptions
- Total Dataset: 50,000,000 key-value pairs.
- Key Size: Average 64 bytes.
- Value Size: Average 1 KB.
- Traffic Split: 800,000 reads/sec (80%) and 200,000 writes/sec (20%).
What Your Design Should Cover
- Capacity Planning: Compute the memory, storage, and network bandwidth requirements for the cluster.
- Data Partitioning & Routing: How keys are distributed across nodes, how hot partitions are avoided, and how clients locate keys.
- Replication & Consistency: How data is replicated across nodes, node failure handling, and quorum models (R + W > N).
- Storage Engine: Internal storage architecture on individual nodes (e.g., in-memory hash map vs. LSM-tree vs. B-Tree) to meet latency and durability targets.
- Trade-offs: Address the trade-offs between network bandwidth, consistency models, and operational complexity.
Hints
Hint 1
Calculate the raw data footprint for 50 million 1 KB records to determine whether the entire dataset can reside in RAM across a modest cluster.
Hint 2
Use consistent hashing with virtual nodes to balance partitions evenly across storage nodes and minimize data migration when scaling.
Hint 3
Evaluate quorum-based consensus (configurable R, W, and replication factor N) alongside write-ahead logging (WAL) for balancing durability and latency.
Follow-up questions
- How does your architecture handle a hot key receiving 100,000 QPS on a single node?
- How do you synchronize divergent replicas after a network partition resolves (e.g., read repair vs. anti-entropy with Merkle trees)?
- How would your storage engine and caching strategy change if the average value size increased from 1 KB to 1 MB?
Solution walkthrough is for members
Get the full walkthrough with reference code and complexity analysis, plus Kitty Coach at 300 messages a day. Hints, the code runner and community answers stay free.