Caching Strategies & In-Memory Optimization Questions

Designing cache layers to cut redundant work and speed up reads, and the correctness costs that come with them. Covers cache placement across client, CDN, application, and in-memory store tiers, including platform-specific caching on mobile (in-memory and disk caches on iOS and Android, secure on-device token storage) and in the browser (localStorage, IndexedDB, Service Workers). Covers eviction policies, TTLs, write-through vs write-back, warming, and invalidation, plus cache stampede and thundering-herd mitigation when a hot key expires under load. Also covers using an in-memory store like Redis directly rather than only as a cache: distributed locks, counters, rate limiters, and leaderboards. Includes distributed and sharded cache architecture (replication, failover, sizing, migration) and the operational side of running one: health monitoring, alerting, and incident runbooks, plus the security and privacy risks caching introduces, such as cache poisoning and caching PII across shared tenants. Emphasizes hit-rate reasoning and the staleness/consistency trade-offs caching introduces.

HardTechnical
47 practiced

Given a workload where object access frequencies follow a Zipf distribution (skew), explain how LRU and TTL-based eviction policies will affect steady-state cache hit ratio. Given: 1M unique objects, cache capacity 100k items, Zipf parameter s=0.8. Describe how to approximate hit ratio, and discuss how increasing skew changes tuning decisions.

HardSystem Design
48 practiced

Describe distributed cache invalidation patterns for backend caches when many services and regions hold cached copies of objects. Propose an implementation using Redis Pub/Sub or Kafka to broadcast invalidations, and explain how a mobile client could rely on that mechanism (directly or via push) to keep its cache consistent. Discuss fanout limitations and mitigations.

HardTechnical
56 practiced

Given observed traffic (QPS), object-size distribution (mean and variance), expected working set distribution (for example Zipf with parameter s), and an acceptable miss-latency budget, derive a method to calculate required cache memory to achieve a target hit rate. Show formulas, explain assumptions, and describe conservative buffers to account for TTL and growth.

MediumTechnical
48 practiced

You're sizing a Redis cluster for a service that expects 50k RPS of short reads and occasional writes. Each cached value averages 2KB, and you want 2x headroom and replication for durability. Sketch the calculation to estimate memory per node, number of shards, and approximate network/connection requirements.

MediumSystem Design
53 practiced

Design a session caching approach using Redis for a SaaS product serving 50 million monthly active users. Discuss memory estimation, TTL strategy, stickiness vs stateless sessions, clustering, eviction policies, and how you would handle global distribution and failover.

Unlock Full Question Bank

Get access to all Caching Strategies & In-Memory Optimization interview questions and detailed answers.

Sign in to Continue

Join thousands of developers preparing for their dream job.