Practice
Solution
Step 1: Identify storage with native TTL support
Redis supports automatic expiration of keys with TTL, avoiding manual cleanup overhead.Step 2: Evaluate alternatives
Relational DB with batch jobs (A) adds latency and complexity; file systems (C) lack efficient expiration; NoSQL without TTL (D) requires expensive filtering.Final Answer:
Option D -> Option DQuick Check:
Redis TTL automates expiration, reducing operational complexity [check]
Solution
Step 1: Identify need for immediate, atomic invalidation
Price updates require instant invalidation of all related pages to avoid stale data.Step 2: Evaluate strategies
Long TTL with manual purge delays invalidation; short TTL causes high cache misses; client-side headers don't guarantee server cache invalidation; surrogate keys enable atomic invalidation of related content.Final Answer:
Option A -> Option AQuick Check:
Surrogate keys enable atomic, immediate invalidation of related cache [check]
Solution
Step 1: Analyze skew and query patterns
Skewed activity causes hotspots; static range or hash sharding can't adapt dynamically.Step 2: Evaluate strategies
Directory-based sharding allows dynamic assignment of hot users to dedicated shards, balancing load and reducing cross-shard queries.Final Answer:
Option A -> Option AQuick Check:
Directory-based sharding supports dynamic load balancing [check]
Solution
Step 1: Compare latency and scalability
Synchronous DB updates cause high latency and DB bottlenecks; client-side counters are untrustworthy; service-layer without persistence risks data loss.Step 2: Evaluate distributed in-memory counters
API Gateway counters provide low latency and scalability; async DB sync ensures eventual consistency and durability.Final Answer:
Option D -> Option DQuick Check:
Distributed in-memory counters balance latency and scalability [check]
Solution
Step 1: Identify Redis command processing model
Redis processes commands single-threaded, limiting throughput regardless of hardware.Step 2: Analyze scaling impact
At 10x scale, Redis becomes the bottleneck as it cannot process atomic increments fast enough.Step 3: Evaluate other components
API servers can be scaled horizontally; network and clients are less likely to fail first.Final Answer:
Option C -> Option CQuick Check:
Redis single-threaded processing limits throughput at high scale [check]
