0
0
HLDsystem_design~20 mins

Distributed caching (Redis, Memcached) in HLD - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Distributed Cache Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Architecture
intermediate
2:00remaining
Designing a distributed cache with Redis

You need to design a distributed caching layer using Redis for a web application that handles millions of users. Which architecture component is essential to ensure data consistency and high availability?

ADeploy Redis as a single instance on a powerful server
BUse Redis Sentinel for automatic failover and monitoring
CUse Memcached with no replication for simplicity
DStore cache data only on the application server memory
Attempts:
2 left
💡 Hint

Think about how Redis handles failover and keeps the cache available during node failures.

scaling
intermediate
2:00remaining
Scaling Memcached for large datasets

Your application uses Memcached to cache user session data. The dataset is growing beyond the capacity of a single Memcached server. What is the best approach to scale Memcached horizontally?

AUse Redis instead because Memcached cannot scale horizontally
BIncrease the RAM of the single Memcached server to hold all data
CUse consistent hashing to distribute keys across multiple Memcached nodes
DStore all data in a single Memcached node and replicate it to others
Attempts:
2 left
💡 Hint

Consider how Memcached clients decide which server to use for a given key.

tradeoff
advanced
2:00remaining
Choosing between Redis and Memcached for session caching

Your team must choose between Redis and Memcached for caching user sessions. Which tradeoff is most important when deciding?

ARedis supports data persistence and complex data types, Memcached is simpler and faster for pure key-value caching
BMemcached supports transactions, Redis does not
CRedis cannot scale horizontally, Memcached can
DMemcached supports data persistence, Redis does not
Attempts:
2 left
💡 Hint

Think about features and use cases of Redis and Memcached.

🧠 Conceptual
advanced
2:00remaining
Cache invalidation strategies in distributed caching

Which cache invalidation strategy is best suited for a distributed cache to maintain data freshness without overwhelming the backend database?

AWrite all updates only to the cache and never to the database
BAlways delete cache entries immediately after every database update
CNever expire cache entries and rely on manual cache clearing
DUse time-to-live (TTL) expiration combined with lazy loading on cache miss
Attempts:
2 left
💡 Hint

Consider balancing freshness and load on the database.

estimation
expert
3:00remaining
Estimating cache capacity for a high-traffic system

Your system expects 10 million active users, each with an average session size of 2 KB. You want to cache 30% of active sessions simultaneously in Redis. Estimate the minimum memory required for the Redis cache, considering 20% overhead for metadata and replication.

AApproximately 7.2 GB
BApproximately 4.8 GB
CApproximately 12 GB
DApproximately 3.6 GB
Attempts:
2 left
💡 Hint

Calculate total data size, then add overhead.