Bird
Raised Fist0
HLDsystem_design~12 mins

Design a key-value store in HLD - Architecture Diagram

Choose your learning style9 modes available
System Overview - Design a key-value store

This system stores and retrieves data as key-value pairs. It must handle many requests quickly and keep data safe and consistent. The system should scale to support many users and large data volumes.

Architecture Diagram
User
  |
  v
Load Balancer
  |
  v
API Gateway
  |
  v
+-------------------+      +-------------+
|   Key-Value Store  |<---->|   Cache     |
|     Service       |      +-------------+
|  (Handles logic)  |
+-------------------+
          |
          v
    +-------------+
    |  Database   |
    +-------------+
Components
User
client
Sends requests to store or retrieve key-value data
Load Balancer
load_balancer
Distributes incoming requests evenly to API Gateway instances
API Gateway
api_gateway
Receives requests, handles authentication, and routes to Key-Value Store Service
Key-Value Store Service
service
Processes requests, checks cache, and interacts with the database
Cache
cache
Stores frequently accessed key-value pairs for fast retrieval
Database
database
Stores all key-value pairs persistently and reliably
Request Flow - 11 Hops
UserLoad Balancer
Load BalancerAPI Gateway
API GatewayKey-Value Store Service
Key-Value Store ServiceCache
CacheKey-Value Store Service
Key-Value Store ServiceDatabase
DatabaseKey-Value Store Service
Key-Value Store ServiceCache
Key-Value Store ServiceAPI Gateway
API GatewayLoad Balancer
Load BalancerUser
Failure Scenario
Component Fails:Database
Impact:Writes fail and new data cannot be saved; reads may serve stale data from cache
Mitigation:Use database replication and failover to backup; cache serves reads temporarily; alert system admins
Architecture Quiz - 3 Questions
Test your understanding
Which component handles distributing user requests to multiple API Gateway instances?
ACache
BDatabase
CLoad Balancer
DKey-Value Store Service
Design Principle
This design uses caching to speed up reads and reduce database load. The load balancer and API gateway ensure scalability and security. The database provides reliable storage. This layered approach balances speed, reliability, and scalability.