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.

MediumTechnical
77 practiced

Write a Python function that computes a deterministic TTL jitter for cache keys to reduce synchronized expirations. Signature: jitter_ttl(base_ttl_seconds, key, jitter_ratio=0.1) -> ttl_seconds. Ensure the jitter is deterministic per key across nodes but distributes expirations evenly.

MediumTechnical
60 practiced

During a rolling deployment, freshly started instances come up with cold caches, and origin traffic and latency spike until they fill back in. How would you design the rollout to prevent that, and what would you prioritize warming first?

MediumTechnical
58 practiced

Given a SQL-driven product-search endpoint (table: products(id, name, price, stock, updated_at)), propose a query/result caching strategy using materialized views or a dedicated cache. Explain refresh strategy for price or stock updates so users don't see stale critical data while still gaining performance.

HardTechnical
48 practiced

You must deploy a schema change that alters cache key formats across hundreds of microservices. Create a rollout and invalidation plan that avoids long cache inconsistency windows and downtime. Include backward compatibility, migrations, cache warm-up, and rollback steps.

HardSystem Design
47 practiced

Design a global cache architecture for a multi-region web application that requires read latency under 50ms for most users, eventual consistency within 5 seconds, and handles 10M requests per second at peak. Include caching tiers (edge, regional caches, origin), replication, failover, cache-coherency mechanisms and handling of cold-starts.

Unlock Full Question Bank

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

Sign in to Continue

Join thousands of developers preparing for their dream job.