Compare Least Recently Used (LRU) and Least Frequently Used (LFU). In what specific traffic pattern would LFU outperform LRU?
Explain the concept of the 'Clock' or 'Second Chance' eviction policy. How does it approximate LRU with less overhead?
Explain the trade-off between memory usage and hit ratio when sizing a cache.
How does an ARC (Adaptive Replacement Cache) attempt to improve upon standard LRU?
How would you define and measure a 'Cache Hit Ratio'? What does a high hit ratio with high latency suggest about your cache design?
If your cache is primarily storing user session data that expires after 30 minutes of inactivity, which eviction policy would you configure and why?
What happens to a cache when it reaches its memory limit but no TTLs have expired yet?
What is a 'healthy' cache hit ratio, and if your ratio is low, what specific architectural issues or traffic patterns would you investigate?
What is the 'Belady's Anomaly' in the context of FIFO cache eviction?
What is the 'Two-Segment' or 'LRU-K' algorithm, and why might it be better than standard LRU for certain workloads?
When would Most Recently Used (MRU) eviction outperform LRU?
Compare Write-Through, Write-Back (Write-Behind), and Write-Around. What are the data loss risks associated with Write-Back?
Explain the 'Dual Write' problem. How do you ensure the cache and database don't get out of sync during an update?
Explain the trade-off between Write-Through and Write-Back (Write-Behind) caching. Which one would you choose for a system where data loss is unacceptable, and why?
In a cache-aside pattern, on a write should you update the cache or delete (invalidate) the entry? Why is deleting often safer?
What is the fundamental difference between the Cache-Aside (Lazy Loading) pattern and the Read-Through pattern, and in which layer does the loading logic reside for each?
When would you use a Write-Around policy instead of Write-Through, and how does it impact the cache miss rate for subsequent reads?
Why might you prefer moving caching logic into a library or sidecar (Read-Through) rather than handling it manually in your application code?
Invalidation & Consistency
Explain the 'Cache Coherence' problem when using local caches across multiple application instances.
Explain the concept of 'Eventual Consistency' in the context of a cache-aside pattern.
How do you propagate cache invalidation across multiple distributed cache nodes or application instances (e.g., via pub/sub or broadcast messages)?
How does using a versioned key (e.g., user:v2:123) help with cache invalidation during a schema change or deployment?
If your system requires strong consistency, can you still use a cache, and what are the trade-offs in latency if you do?
What is the 'Cache Invalidation' problem, and why is it considered one of the 'two hard things' in computer science?
What is the difference between Strong Consistency and Eventual Consistency in a multi-node cache cluster?
Explain the Cache Avalanche scenario. How can jitter (adding randomness to TTLs) prevent a database from crashing during a mass expiration event?
Explain the difference between 'Cache Penetration' and 'Cache Avalanche'. How do their mitigations differ?
How do you identify and handle a hot key (a single key receiving disproportionately high traffic) in a distributed cache to prevent a single node from becoming a bottleneck?
How does 'Negative Caching' help protect your downstream database?
How does a Bloom filter actually work, and why are false positives (but not false negatives) acceptable when using it to guard a cache?
What is a Cache Stampede, and how does request coalescing or locking prevent multiple concurrent requests from recomputing the same expensive value?
What is Cache Penetration, how does it differ from a standard cache miss, and why is negative caching or a bloom filter used to solve it?
What is the difference between a cache avalanche and a cache stampede?
Explain the Cache-Control: no-cache vs. no-store directives. Which one allows the browser to keep a copy?
Explain the difference between freshness (Cache-Control/Expires) and validation (ETag/Last-Modified) in HTTP caching. When does a browser send a Conditional GET?
Explain the public vs. private directives in Cache-Control. Why is this distinction critical for security when caching authenticated responses?
How do ETags work to facilitate conditional GET requests, and how does this save bandwidth?
What happens to a cached resource when a 'Conditional GET' (If-None-Match) returns a 304 Not Modified?
What is the difference between 'Strong Validation' (ETags) and 'Weak Validation' in HTTP caching?
What is the difference between the ETag and Last-Modified headers?
What is the purpose of the Vary HTTP header in caching, and how does it prevent a mobile user from receiving a cached desktop version of a page?
Explain the difference between sharding (partitioning) and replication in a cache cluster. Which one helps with read throughput, and which one helps with storage capacity?
From a high-level architectural perspective, why might you choose Redis over Memcached (or vice-versa) for a caching layer?
How does consistent hashing minimize cache misses when adding or removing a node from a distributed cache cluster?
In a distributed system, how do you ensure cache coherence across different geographical regions?
What is 'Multi-level Caching' (L1/L2 application caches), and how do you manage the complexity of multiple layers?
What is 'Near Caching' and how does it leverage both local and distributed layers?
What is Consistent Hashing, and why is it preferred over simple 'mod N' hashing for distributing cache keys across a cluster?
What is the difference between an In-Process (Local) cache and a Distributed (Remote) cache? When would you choose one over the other?
Explain the Stale-While-Revalidate pattern. How does it improve user-perceived latency while still ensuring data eventually becomes fresh?
How do you determine the optimal TTL (Time-to-Live) for a specific piece of data?
How does a sliding TTL differ from a fixed TTL?
What is 'Refresh-Ahead' caching, and how does it help in reducing tail latency?
What is the difference between active (eager) expiration and lazy (passive) expiration of TTL'd entries, and what are the trade-offs?
What is the difference between evicting data based on a Time-To-Live (TTL) versus evicting based on memory pressure (Max-Memory), and can a key be evicted before its TTL expires?
What is the difference between explicit (event-based) invalidation and time-based (TTL) expiration, and when would you combine them?
What is the purpose of cache warming or pre-warming, and when is it necessary to do this before a deployment or high-traffic event?
How does the principle of temporal and spatial locality justify the use of a cache in the first place?
Under what circumstances might adding a cache actually increase the overall latency of a request?
What are virtual nodes in consistent hashing and what problem do they solve?
What characteristics make a piece of data a good candidate for caching versus a poor one?
What is a cache, and what are the primary reasons for adding one to a system?
What is the difference between a cache hit and a cache miss, and what do we mean by a 'cold' versus a 'warm' cache?
What is the difference between memoization and caching?
What makes a good cache key? What pitfalls should you avoid when designing cache keys?
When is caching actually a bad idea? Can you name scenarios where adding a cache would decrease performance or reliability?
Why is the choice of serialization format (JSON vs. Protobuf vs. Binary) important when designing a high-performance caching layer?
Why might you choose NOT to cache a piece of data even if it is frequently accessed?