0
0
HLDsystem_design~12 mins

Why caching reduces latency in HLD - Architecture Impact

Choose your learning style9 modes available
System Overview - Why caching reduces latency

This system shows how caching helps reduce the time it takes to get data. When a user asks for information, the system first checks a fast storage called cache. If the data is there, it returns quickly. If not, it gets the data from the slower database and saves it in the cache for next time.

Architecture Diagram
User
  |
  v
Load Balancer
  |
  v
API Gateway
  |
  v
Service
  |
  +-----> Cache
  |         |
  |         v
  +------> Database
Components
User
user
Sends requests to get data
Load Balancer
load_balancer
Distributes incoming requests evenly to services
API Gateway
api_gateway
Handles client requests and routes them to the service
Service
service
Processes requests, checks cache, and fetches data
Cache
cache
Stores frequently accessed data for fast retrieval
Database
database
Stores all persistent data, slower to access
Request Flow - 11 Hops
UserLoad Balancer
Load BalancerAPI Gateway
API GatewayService
ServiceCache
CacheService
ServiceDatabase
DatabaseService
ServiceCache
ServiceAPI Gateway
API GatewayLoad Balancer
Load BalancerUser
Failure Scenario
Component Fails:Cache
Impact:Cache misses increase, causing all requests to hit the slower database, increasing latency
Mitigation:System continues to work by querying the database directly; cache can be restored or replaced without downtime
Architecture Quiz - 3 Questions
Test your understanding
Why does the system check the cache before the database?
ABecause the cache stores all data permanently
BBecause the database is unreliable
CBecause cache is faster to access than the database
DBecause the user requests the cache directly
Design Principle
Caching reduces latency by storing frequently requested data in a fast-access layer. This avoids repeated slow database queries, improving user experience and system efficiency.