0
0
HLDsystem_design~12 mins

Distributed caching (Redis, Memcached) in HLD - Architecture Diagram

Choose your learning style9 modes available
System Overview - Distributed caching (Redis, Memcached)

This system uses distributed caching to speed up data access for users. It stores frequently requested data in fast cache servers like Redis or Memcached, reducing load on the main database and improving response times.

Key requirements include fast reads, cache consistency, and handling cache failures gracefully.

Architecture Diagram
User
  |
  v
Load Balancer
  |
  v
API Gateway
  |
  v
+-------------------+
|   Application      |
|   Servers          |
+-------------------+
  |           |
  v           v
Distributed Cache  Database
 (Redis/Memcached)  (SQL/NoSQL)
Components
User
client
Sends requests to the system
Load Balancer
load_balancer
Distributes incoming user requests evenly to API Gateway instances
API Gateway
api_gateway
Handles client requests, routes them to application servers
Application Servers
service
Processes requests, checks cache, queries database if needed
Distributed Cache
cache
Stores frequently accessed data for fast retrieval
Database
database
Stores persistent data, source of truth
Request Flow - 11 Hops
UserLoad Balancer
Load BalancerAPI Gateway
API GatewayApplication Servers
Application ServersDistributed Cache
Distributed CacheApplication Servers
Application ServersDatabase
DatabaseApplication Servers
Application ServersDistributed Cache
Application ServersAPI Gateway
API GatewayLoad Balancer
Load BalancerUser
Failure Scenario
Component Fails:Distributed Cache
Impact:Cache misses increase, causing more database queries and higher latency
Mitigation:System continues to serve data from database; cache cluster can be restored or replaced without data loss
Architecture Quiz - 3 Questions
Test your understanding
Which component handles distributing user requests evenly to prevent overload?
ADistributed Cache
BLoad Balancer
CAPI Gateway
DDatabase
Design Principle
This architecture uses distributed caching to reduce database load and improve response times by storing frequently accessed data in fast, in-memory cache servers. It ensures scalability and fault tolerance by separating cache and database layers and routing requests through load balancers and API gateways.