09 / 12

Design a high-performance caching layer for a social media platform

Difficulty: 8/10
eviction policies, consistency, sharding

Distributed caching architecture with consistent hashing, load balancing, and automatic cache invalidation, reducing database queries by 90%

Scenario Questions

0-2 years experience

  1. 1How would you add a cache for user‑profile lookups to reduce database load in a small feature?
  2. 2If a cached profile entry expires while a user is scrolling, what does the user see and how does your system handle it?

2-5 years experience

  1. 1We saw latency spikes after a post went viral; how would you debug the caching layer to find the bottleneck?
  2. 2Explain the trade‑offs between write‑through and write‑behind caching for new posts on the timeline.
  3. 3Given a limited cache size, how would you decide which keys to evict and why?

5-8 years experience

  1. 1Design the caching architecture to serve timeline reads for millions of users, covering sharding, replication, and cache invalidation.
  2. 2How would you ensure cache consistency when a user changes their privacy settings that affect what appears in others' feeds?
  3. 3What key metrics would you monitor and how would you auto‑scale the cache tier under load?

8+ years experience

  1. 1Our platform is migrating from a monolithic cache to a multi‑region, edge‑distributed cache; what migration steps and data‑ownership concerns would you address?
  2. 2How would you evaluate the cost‑benefit of adding a CDN‑level cache versus an in‑memory cache for serving media assets?
  3. 3Describe a strategy to keep cache logic maintainable across multiple teams and services over several years.

Follow-up Questions

  • What metrics would you set up to detect a cache stampede?
  • How does your design react to a sudden traffic surge on a viral post?
  • Walk me through a failure scenario and how you would recover.
Share

Share via WhatsApp, X, Facebook, LinkedIn or copy link. Open Graph preview enabled.