Caching Expert
What is a cache, and what are the primary reasons for adding one to a system?
Select the correct answer
A load balancer that distributes incoming requests across many backend app servers
A fast store of data copies that lowers latency and reduces load on the source
A queue that buffers write requests so the backing store is updated asynchronously
A backup database replica kept in sync to provide durability if the primary fails
What is the difference between a cache hit and a cache miss, and what do we mean by a 'cold' versus a 'warm' cache?
Select the correct answer
Hit finds data in cache, miss does not; cold is unpopulated, warm is populated
Hit means data is fresh, miss means data is stale; cold is old, warm is recently written
Hit is a successful eviction, miss is a failed one; cold has low memory, warm has high
Hit writes to cache, miss reads from cache; cold is slow startup, warm is steady state
What is the difference between memoization and caching?
Select the correct answer
Memoization is used for databases while caching applies only to pure side functions.
Caching requires manual invalidation but memoization automatically refreshes entries.
Memoization stores function results by arguments; caching is the broader concept.
Caching only works in memory while memoization always persists its results to disk.
When is caching actually a bad idea? Can you name scenarios where adding a cache would decrease performance or reliability?
Select the correct answer
When the dataset is large but reads vastly outnumber writes across all keys
When the backing store is slow and cannot keep up with incoming read traffic
When many clients repeatedly request the same small set of hot keys
When data changes constantly so cached entries are stale before they are reused
How does the principle of temporal and spatial locality justify the use of a cache in the first place?
Select the correct answer
Network bandwidth grows over time, so cached copies become cheaper to serve later
Data access is uniformly random, so caching any subset reduces total latency equally
Recently used data and nearby data are likely reused soon, so caching them pays off
Writes always follow reads, so caching write buffers improves overall throughput greatly
Why might you choose NOT to cache a piece of data even if it is frequently accessed?
Select the correct answer
It requires strong consistency or freshness that a cache cannot reliably guarantee
It is too small to provide any meaningful memory savings when stored in the cache
The eviction policy would prioritize it and push out other more valuable entries
Frequently accessed data is already fast to fetch, so caching offers no real benefit
Under what circumstances might adding a cache actually increase the overall latency of a request?
Select the correct answer
When hit rates are low, each miss adds a lookup before fetching from the source
When hit rates are high, the cache must constantly evict entries to free memory space
When reads dominate writes, the cache invalidation logic blocks incoming requests
When the cache is colocated with the application server reducing network round trips
What makes a good cache key? What pitfalls should you avoid when designing cache keys?
Select the correct answer
It relies on random identifiers so that different requests never collide in store.
It stays as short as possible, omitting parameters to save memory on the server.
It deterministically encodes all inputs that affect the result and stays unique.
It uses the current timestamp so that every incoming request gets a fresh value.
What characteristics make a piece of data a good candidate for caching versus a poor one?
Select the correct answer
Data that is unique per request and rarely accessed more than a single time overall.
Data written far more often than it is read and tolerant of being slightly stale now.
Data read frequently, changing rarely, and expensive to compute or fetch each time.
Data that must stay perfectly consistent and changes on essentially every request made.
What are virtual nodes in consistent hashing and what problem do they solve?
Select the correct answer
Multiple ring positions per physical node, spreading keys more evenly across nodes
In-memory shards that store the hash ring metadata separately from the actual data
Backup replica nodes that take over only when a primary physical node fails completely
Temporary nodes added during rehashing to cache keys while the ring rebalances fully
Why is the choice of serialization format (JSON vs. Protobuf vs. Binary) important when designing a high-performance caching layer?
Select the correct answer
It determines payload size and encode/decode speed, affecting latency and throughput
It decides which eviction policy the cache uses to remove old entries from memory
It controls how cache keys are hashed and distributed across the cluster of nodes
It defines the network protocol used between clients and the distributed cache servers
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?
Select the correct answer
Both load through the application, but cache-aside writes sync and read-through async.
In cache-aside the cache loads on a miss; in read-through the application loads it.
In cache-aside the application loads on a miss; in read-through the cache loads it.
Both load through the cache layer, differing only in their eviction and expiry rules.
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?
Select the correct answer
Write-Back persists to the database synchronously; choose it since loss is unacceptable here.
Write-Through defers database writes for throughput; choose it since loss is unacceptable.
Write-Back writes through immediately on each update; choose it since loss is unacceptable.
Write-Through persists to the database synchronously; choose it since loss is unacceptable.
When would you use a Write-Around policy instead of Write-Through, and how does it impact the cache miss rate for subsequent reads?
Select the correct answer
Use it for read-heavy hot data; recently written items are then served from cache faster.
Use it for data needing strong consistency; it lowers the miss rate on every later read.
Use it when writes are rare but reads frequent; it eliminates misses right after a write.
Use it for write-heavy rarely-read data; recently written items cause more read misses.
Compare Write-Through, Write-Back (Write-Behind), and Write-Around. What are the data loss risks associated with Write-Back?
Select the correct answer
Write-Back duplicates every write, risking loss if both copies are evicted at one moment.
Write-Back acknowledges from the cache before persisting, risking loss if the cache fails.
Write-Back skips the cache entirely, risking loss if the network fails before each write.
Write-Back persists synchronously first, risking loss if the database fails before a flush.
Explain the 'Dual Write' problem. How do you ensure the cache and database don't get out of sync during an update?
Select the correct answer
Reading from two caches returns stale data; fix it by always querying the primary node.
Writing the same key twice wastes memory; resolve it by deduplicating keys on each insert.
Writing to two replicas at once causes deadlocks; resolve it by locking both rows first.
Updating cache and DB as two steps risks inconsistency; invalidate the cache on writes.
Why might you prefer moving caching logic into a library or sidecar (Read-Through) rather than handling it manually in your application code?
Select the correct answer
It eliminates the need for any eviction or expiration policies at all.
It always lowers latency by caching the data on local disk storage.
It guarantees strict consistency between the cache and the database.
It centralizes cache logic so services avoid duplicating fragile code.
In a cache-aside pattern, on a write should you update the cache or delete (invalidate) the entry? Why is deleting often safer?
Select the correct answer
Delete it, because updating a cache is impossible in cache-aside designs.
Delete it, since invalidation avoids serving stale data after write races.
Update it, because deletion forces an expensive full table reload each time.
Update it, since rewriting always keeps the cache and database in sync.
What happens to a cache when it reaches its memory limit but no TTLs have expired yet?
Select the correct answer
It flushes the entire cache and starts cold to guarantee free memory now exists.
It rejects all new writes until some existing key's TTL eventually expires soon.
It evicts existing entries based on its configured eviction policy to free space.
It spills the overflow entries onto disk automatically without evicting anything.
Compare Least Recently Used (LRU) and Least Frequently Used (LFU). In what specific traffic pattern would LFU outperform LRU?
Select the correct answer
When access is uniformly random with no items favored over any of the others.
When a stable hot set is repeatedly accessed amid occasional scanning traffic.
When the working set rotates completely on every short interval time window.
When recent items are far more likely to be requested again very soon after.
How would you define and measure a 'Cache Hit Ratio'? What does a high hit ratio with high latency suggest about your cache design?
Select the correct answer
Hits divided by total lookups; high hit ratio with high latency means the cache layer itself is slow.
Hits divided by total writes; high hit ratio with high latency means the backing database is overloaded.
Reads divided by total memory; high hit ratio with high latency means the cached objects are too large.
Misses divided by total lookups; high hit ratio with high latency means the cache is badly undersized.
Explain the trade-off between memory usage and hit ratio when sizing a cache.
Select the correct answer
Hit ratio is fixed by the workload, so adding memory only wastes resources without any real benefit.
Less memory raises the hit ratio because a smaller cache keeps only the hottest items always resident.
More memory raises the hit ratio but with diminishing returns, so added cost eventually outweighs gains.
More memory always lowers the hit ratio because a larger cache scans more entries on every lookup.
If your cache is primarily storing user session data that expires after 30 minutes of inactivity, which eviction policy would you configure and why?
Select the correct answer
An expire-after-write policy that removes each session 30 minutes after the moment it was first created.
A least-recently-used policy that evicts the oldest entries only once the cache reaches its capacity.
An expire-after-access (idle TTL) policy that resets the timer on each access and evicts after inactivity.
A first-in-first-out policy that evicts the earliest written sessions regardless of any recent activity.
When would Most Recently Used (MRU) eviction outperform LRU?
Select the correct answer
During bursty write workloads where the newest entries are almost always the next ones to be read back.
During random-access workloads where every item has an equal and independent probability of being reused.
During repeated sequential scans of a dataset larger than the cache, where old items are reused soonest.
During workloads with a small hot set that is accessed far more frequently than everything else stored.
What is a 'healthy' cache hit ratio, and if your ratio is low, what specific architectural issues or traffic patterns would you investigate?
Select the correct answer
Typically above 90%; if low, examine cache size, key cardinality, and TTLs.
Always exactly 100%; if low, the underlying cache hardware is surely failing.
Around 10% normally; if low, just raise TTLs and ignore the traffic patterns.
Typically below 50%; if low, disable caching entirely to conserve memory use.
Explain the concept of the 'Clock' or 'Second Chance' eviction policy. How does it approximate LRU with less overhead?
Select the correct answer
It scans a circular buffer using a reference bit to skip recently used pages.
It evicts pages strictly in insertion order regardless of any later accesses.
It counts the access frequency per page and evicts the least used one of all.
It tracks exact access timestamps to evict the strictly oldest accessed page.
What is the 'Belady's Anomaly' in the context of FIFO cache eviction?
Select the correct answer
Frequently accessed pages get evicted before rarely accessed ones in LFU.
Removing cache slots can paradoxically decrease the miss rate under LRU.
Cache hit rate stays constant no matter how many slots FIFO is given here.
Adding more cache slots can increase the miss rate under FIFO eviction.
How does an ARC (Adaptive Replacement Cache) attempt to improve upon standard LRU?
Select the correct answer
It doubles the cache size automatically whenever the hit ratio drops too low.
It evicts by frequency only, ignoring recency to favor long-term popular keys.
It replaces timestamps with a single reference bit to reduce tracking overhead.
It balances recency and frequency lists, adapting their sizes to the workload.
What is the 'Two-Segment' or 'LRU-K' algorithm, and why might it be better than standard LRU for certain workloads?
Select the correct answer
It splits the cache into two equal halves and evicts from whichever half is currently larger.
It tracks only the single most recent access and always evicts the newest item that was added.
It remembers the Kth-most-recent access of each item so one-time scans don't evict hot data.
It uses two random samples on each eviction to approximate LRU with far less metadata overhead.
What happens to a cached resource when a 'Conditional GET' (If-None-Match) returns a 304 Not Modified?
Select the correct answer
The cached copy is served and its freshness lifetime is renewed without downloading the body
The cached copy is discarded and the full resource is re-downloaded from the origin server
The cached copy is served but immediately marked stale, forcing another request next time
The cached copy's body is partially updated using the delta returned within the response
Explain the Cache-Control: no-cache vs. no-store directives. Which one allows the browser to keep a copy?
Select the correct answer
no-cache forbids storage, while no-store stores a copy reused without revalidation.
Both directives forbid storage, so neither one ever allows the browser to keep a local copy.
no-store lets the browser store a copy but it must revalidate with the server before reuse.
no-cache lets the browser store a copy but it must revalidate with the server before reuse.
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?
Select the correct answer
It tells caches to key entries on headers like User-Agent, storing separate mobile and desktop copies.
It tells the origin server to compress responses differently for mobile clients to reduce bytes sent.
It tells caches how long entries may live before they must be revalidated against the origin server.
It tells browsers to vary request order so the mobile and desktop versions load in different priorities.
How do ETags work to facilitate conditional GET requests, and how does this save bandwidth?
Select the correct answer
The server compares timestamps in Last-Modified and resends the full body only when the bytes differ.
The client sends the stored ETag in If-Modified-Since; an unchanged resource returns 200 with no body.
The client sends a HEAD request first and downloads the body only if the content length has changed.
The client sends the stored ETag in If-None-Match; an unchanged resource returns 304 with no body.
Explain the public vs. private directives in Cache-Control. Why is this distinction critical for security when caching authenticated responses?
Select the correct answer
private disables all caching entirely while public forces revalidation on each single request
public encrypts responses for shared caches while private compresses them for browsers only
private restricts storage to the user's browser; public permits shared proxy caches to store it
public restricts storage to the user's browser; private permits shared proxy caches to store it
What is the difference between the ETag and Last-Modified headers?
Select the correct answer
ETag is an opaque identifier of content; Last-Modified is a timestamp of the last change
ETag is sent only by clients in requests; Last-Modified is sent only in server responses
ETag stores the resource's size in bytes; Last-Modified stores the MIME type of content
Last-Modified is an opaque identifier of content; ETag is a timestamp of the last change
Explain the difference between freshness (Cache-Control/Expires) and validation (ETag/Last-Modified) in HTTP caching. When does a browser send a Conditional GET?
Select the correct answer
Freshness applies only to images; a Conditional GET is sent only for HTML documents and scripts
Freshness forces revalidation on each request; a Conditional GET is sent for every cached resource
Validation avoids server contact while fresh; a Conditional GET is sent before the response is stale
Freshness avoids server contact while fresh; a Conditional GET is sent once the response is stale
What is the difference between 'Strong Validation' (ETags) and 'Weak Validation' in HTTP caching?
Select the correct answer
Strong validation uses Last-Modified timestamps; weak validation uses hashed ETag values
Strong validation requires byte-for-byte identical resources; weak validation allows semantically equivalent ones
Strong validation works only over HTTPS; weak validation operates on plain HTTP connections only
Strong validation allows semantically equivalent resources; weak validation requires byte-for-byte identical ones
How does a sliding TTL differ from a fixed TTL?
Select the correct answer
Sliding TTL expires at a fixed wall-clock time, while fixed TTL extends on every read access
Sliding TTL applies only to writes, while fixed TTL applies only to read operations of keys
Sliding TTL resets the expiry on each access, while fixed TTL expires at a set time after write
Sliding TTL guarantees stronger consistency, while fixed TTL allows serving arbitrarily stale data
Explain the Stale-While-Revalidate pattern. How does it improve user-perceived latency while still ensuring data eventually becomes fresh?
Select the correct answer
Block the request until revalidation completes, then serve only the freshly fetched content
Serve stale content instantly while revalidating in the background for the next request
Serve stale content instantly and skip revalidation until the cache is manually purged later
Reject stale content instantly and return an error while revalidation occurs in background
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?
Select the correct answer
Increase the cache's memory limit before traffic to prevent evictions during peak demand
Pre-expire cache entries before traffic so the cache revalidates everything during the event
Flush the cache before traffic so stale entries don't serve outdated data during the event
Pre-populate the cache before traffic so a cold cache won't cause a flood of misses
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?
Select the correct answer
TTL evicts on time expiry; memory pressure only rejects new writes, never removing keys
TTL evicts by policy on memory limits; memory pressure evicts on time, never before TTL
TTL evicts on time expiry; memory pressure evicts by policy, so keys can go before TTL
Both evict only on time expiry, so a key can never be removed before its TTL elapses
How do you determine the optimal TTL (Time-to-Live) for a specific piece of data?
Select the correct answer
Use a fixed global value of five minutes for every key regardless of its access
Always match it to the database's transaction log retention window for consistency
Set it to the longest possible value so the cache hit rate is always maximized
Balance how often the data changes against tolerance for staleness and backend load
What is the difference between active (eager) expiration and lazy (passive) expiration of TTL'd entries, and what are the trade-offs?
Select the correct answer
Active removes keys only on access; lazy scans the keyspace continuously, trading memory for CPU
Active proactively removes expired keys; lazy removes them only on access, trading CPU for memory
Active never frees memory until eviction; lazy frees it immediately on every single write operation
Active applies to writes only; lazy applies to reads only, with essentially no memory trade-offs
What is the difference between explicit (event-based) invalidation and time-based (TTL) expiration, and when would you combine them?
Select the correct answer
Explicit invalidation guarantees no stale reads ever; TTL guarantees the same with less coding
Explicit invalidation works only in single-node caches; TTL works only in distributed clusters
Explicit removes entries on data-change events for freshness; TTL expires them as a safety net
Explicit invalidation expires entries on a timer; TTL removes them only when source data changes
What is 'Refresh-Ahead' caching, and how does it help in reducing tail latency?
Select the correct answer
It delays refresh until after expiry, serving stale data while a background job recomputes it
It proactively refreshes frequently-accessed entries before expiry so reads avoid waiting on recompute
It pre-loads the entire dataset into cache at startup to avoid all runtime database queries
It refreshes every entry on a fixed schedule regardless of access, eliminating all cache misses
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?
Select the correct answer
Requests for non-existent keys always miss and hit the database; negative caching or bloom filters block them
Requests overflow the cache memory limit and evict entries; negative caching frees room for them quickly
Requests bypass the cache layer entirely by design; bloom filters reroute them back through the cache again
Requests for expired keys repeatedly recompute the value; bloom filters store the recomputed results instead
Explain the Cache Avalanche scenario. How can jitter (adding randomness to TTLs) prevent a database from crashing during a mass expiration event?
Select the correct answer
The whole cache server goes offline at once; randomizing TTLs makes clients retry their failed lookups at staggered intervals later.
Stale entries are served past expiry forever; randomizing TTLs forces periodic refreshes so the database stays fully consistent always.
Many keys expire simultaneously, flooding the database; randomizing TTLs spreads expirations across time to smooth the load.
A single popular key expires and many requests rebuild it at once; randomizing TTLs delays each request before reading from cache.
Explain the difference between 'Cache Penetration' and 'Cache Avalanche'. How do their mitigations differ?
Select the correct answer
Penetration is requests for nonexistent keys hitting the DB, fixed by negative caching or Bloom filters; avalanche is mass expiry, fixed by TTL jitter.
Penetration is serving stale data fixed by shorter TTLs; avalanche is too many writes fixed by batching updates before they reach the database.
Penetration is one hot key rebuilt by many threads fixed by locking; avalanche is the cache crashing fixed by adding replica failover nodes.
Penetration is mass simultaneous expiry fixed with TTL jitter; avalanche is nonexistent-key requests fixed with negative caching or Bloom filters.
How does 'Negative Caching' help protect your downstream database?
Select the correct answer
It caches error responses briefly and retries the database automatically until a valid value is eventually found and stored.
It blocks all requests for unknown keys at the load balancer so they never reach the cache or the database tier at all.
It stores a marker for missing keys so repeated lookups for them are answered by the cache rather than the database.
It keeps frequently failed queries in a separate queue so the database can process them in batches during off-peak hours.
What is a Cache Stampede, and how does request coalescing or locking prevent multiple concurrent requests from recomputing the same expensive value?
Select the correct answer
Many requests miss at once and recompute the same value; coalescing lets one compute while others wait
Expired keys accumulate and exhaust memory; coalescing merges them into one entry to free space quickly
A single request floods the cache with writes; locking blocks all reads until the write completes safely
Concurrent requests overwrite each other's writes; locking serializes the writes to keep data consistent
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?
Select the correct answer
Replicate the key across multiple nodes or add a local in-process cache to spread the load
Shard the key by hashing its value so each request lands on a different random node
Delete the hot key periodically to force the traffic back to the database tier instead
Increase the key's TTL indefinitely so it is recomputed less often on the overloaded node
What is the difference between a cache avalanche and a cache stampede?
Select the correct answer
Avalanche is the cache cluster losing a node and remapping keys; stampede is clients retrying failed reads faster than the DB can serve.
Avalanche is stale data served after expiry; stampede is the database returning duplicate rows when several caches refresh themselves together.
Avalanche is requests for keys that never existed reaching the DB; stampede is a single client sending too many requests in a short burst.
Avalanche is many different keys expiring together overwhelming the DB; stampede is many requests rebuilding the same expired key at once.
How does a Bloom filter actually work, and why are false positives (but not false negatives) acceptable when using it to guard a cache?
Select the correct answer
It hashes items into a shared bit array; a false positive only triggers a needless lookup, but a false negative would skip existing data.
It keeps a counter per key in memory; a false positive slows writes slightly, but a false negative would let duplicate keys be inserted twice over.
It compresses keys into hashed buckets on disk; a false positive returns stale data, but a false negative would permanently lose a cached value.
It stores full keys in a sorted tree; a false positive wastes memory, but a false negative would corrupt the cache by overwriting valid entries.
What is the difference between an In-Process (Local) cache and a Distributed (Remote) cache? When would you choose one over the other?
Select the correct answer
In-process persists data to disk for durability; distributed only holds data in volatile memory and loses everything whenever a single node restarts.
In-process lives in the app's own memory and is fastest but unshared; distributed runs as a shared service with network cost but consistency.
In-process scales horizontally by adding nodes automatically; distributed is limited to one machine's RAM and cannot grow beyond that fixed capacity.
In-process is shared across all servers over the network; distributed is private per instance and avoids any serialization or coherence problems entirely.
How does consistent hashing minimize cache misses when adding or removing a node from a distributed cache cluster?
Select the correct answer
Keys are replicated to every node in the ring, so when one node leaves another already holds the data and no misses can occur at all.
Keys are mapped around a hash ring, so only keys belonging to the changed node move, leaving most keys on their existing nodes.
Keys are reassigned evenly across all nodes on each change, which balances load perfectly while invalidating only a tiny part of the cache.
Keys are rehashed with a new modulus on every change, but the ring caches the old results so lookups still resolve to the same node.
What is Consistent Hashing, and why is it preferred over simple 'mod N' hashing for distributing cache keys across a cluster?
Select the correct answer
It sorts keys into ranges per node so adding a node splits one range only, while mod N distributes keys randomly and cannot be rebalanced.
It replicates keys across all nodes so failures cause no remapping at all, while mod N stores each key on one node without redundancy.
It assigns keys by modulus of a fixed prime so changing nodes shifts only a few keys, while mod N must move every key to a new node.
It maps keys and nodes onto a ring so adding or removing a node remaps only a fraction of keys, unlike mod N which remaps nearly all.
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?
Select the correct answer
Sharding copies the full dataset to every node for redundancy, while replication splits keys to improve overall write throughput.
Both sharding and replication mainly improve write latency, but neither one increases the total storage capacity that is available.
Replication spreads data across nodes to add storage capacity, while sharding copies data to extra nodes to raise read throughput.
Sharding spreads data across nodes to add storage capacity, while replication copies data to extra nodes to raise read throughput.
From a high-level architectural perspective, why might you choose Redis over Memcached (or vice-versa) for a caching layer?
Select the correct answer
Memcached offers rich data structures, persistence, and replication, whereas Redis is a simpler single-threaded key-value store.
Redis offers rich data structures, persistence, and replication, whereas Memcached is a simpler multithreaded key-value store.
Both store only strings, but Redis scales reads better while Memcached is the sole option that supports clustering.
Redis is purely volatile with no persistence, whereas Memcached can durably store complex nested data structures on disk.
What is 'Multi-level Caching' (L1/L2 application caches), and how do you manage the complexity of multiple layers?
Select the correct answer
It splits one cache into read and write halves on separate hosts; complexity is managed by syncing them with periodic full reloads.
It tiers caches purely by key size rather than speed or scope; complexity is managed by hashing each key to the correct storage tier.
It pairs a fast in-process L1 cache with a larger shared L2 cache; complexity is managed by coordinating invalidation across layers.
It runs two identical distributed caches in parallel for redundancy; complexity is managed by routing every single read to both layers.
What is 'Near Caching' and how does it leverage both local and distributed layers?
Select the correct answer
It places the cache physically near the database server, letting queries skip the network hop to the application tier.
It routes every request first to the distributed cache, falling back to a local cache only when the remote nodes are offline.
It keeps a small local copy of hot entries in the app, backed by a distributed cache that holds the full shared dataset.
It keeps the entire dataset in app memory only, using the distributed cache solely as a write-behind durable backup store.
In a distributed system, how do you ensure cache coherence across different geographical regions?
Select the correct answer
Use synchronous writes to every region on each update, guaranteeing strong consistency with no added cross-region read latency.
Disable all regional caches and read directly from one global database, ensuring coherence at the cost of much higher latency.
Pin each user permanently to one region's cache only, so coherence never matters because data is never shared across regions.
Use asynchronous replication and invalidation messages between regions, accepting eventual consistency for cross-region reads.
What is the 'Cache Invalidation' problem, and why is it considered one of the 'two hard things' in computer science?
Select the correct answer
Choosing a hash function that distributes keys evenly is hard, and getting it wrong is what causes most stale-data problems.
Allocating enough memory so the cache never evicts any entry is hard, which is why invalidation rarely happens in practice.
Deciding which serialization format to store cached values in is hard, since the wrong choice silently corrupts old entries.
Knowing exactly when cached data becomes stale and must be refreshed or removed is genuinely hard to get right at scale.
How does using a versioned key (e.g., user:v2:123) help with cache invalidation during a schema change or deployment?
Select the correct answer
Bumping the version prefix compresses old entries in place, so both old and new code keep reading the same migrated values.
Bumping the version prefix forces the cache to synchronously delete every old key, blocking reads until the purge completes.
Bumping the version prefix locks all old keys for writes only, letting old code still read them until their TTL expires.
Bumping the version prefix makes old keys unreachable, so new code reads fresh values without deleting the stale entries.
What is the difference between Strong Consistency and Eventual Consistency in a multi-node cache cluster?
Select the correct answer
Eventual consistency returns the latest write on every node instantly; strong consistency allows brief stale reads that converge.
Strong consistency returns the latest write on every node immediately; eventual consistency allows brief stale reads that converge.
Both guarantee the newest value on every read, but strong consistency achieves it faster by skipping inter-node coordination.
Strong consistency means all nodes hold identical data forever; eventual consistency means nodes never synchronize their values.
Explain the concept of 'Eventual Consistency' in the context of a cache-aside pattern.
Select the correct answer
The cache may briefly serve stale data after a write until invalidation or TTL makes it converge.
Reads block until the cache and database are fully synchronized, guaranteeing identical values always.
The database is updated only after every cached copy has been confirmed consistent across all nodes.
The cache always reflects the database immediately because writes update both atomically in one step.
Explain the 'Cache Coherence' problem when using local caches across multiple application instances.
Select the correct answer
A single shared cache locks all instances during writes, blocking reads until updates complete.
Instances overwrite each other's cache entries because they share one memory address space.
Local caches grow unbounded across instances, eventually exhausting memory on every node.
Each instance keeps its own cache copy, so an update on one leaves others serving stale data.
If your system requires strong consistency, can you still use a cache, and what are the trade-offs in latency if you do?
Select the correct answer
Yes, and there is no latency cost because strong consistency removes the need to ever check sources.
No, caching always breaks strong consistency since cached values can never be kept current at all.
Yes, but you must invalidate or validate on each write, adding latency from synchronous coordination.
No, strong consistency requires disabling all reads from memory and serving only from the primary store.
How do you propagate cache invalidation across multiple distributed cache nodes or application instances (e.g., via pub/sub or broadcast messages)?
Select the correct answer
Rely on each node's TTL alone, since broadcasting messages cannot reach all instances reliably.
Have every node poll the database on each read to detect and discard any entries that changed.
Publish an invalidation message on a pub/sub channel so each node evicts the affected key.
Restart every cache node in sequence so they reload fresh values directly from the source store.