Practice
1. A high-traffic web application experiences multiple clients simultaneously requesting the same expired cache key, causing a sudden spike in backend load. Which component or strategy best prevents this thundering herd problem?
easy
Solution
Step 1: Identify the cause of thundering herd
Multiple clients request the same expired cache key simultaneously, causing backend overload.Step 2: Evaluate prevention strategies
Distributed locks or mutexes ensure only one client regenerates the cache, preventing backend overload.Final Answer:
Option A -> Option AQuick Check:
Distributed locking serializes cache regeneration, preventing thundering herd [check]
Hint: Distributed locks serialize cache rebuilds to prevent stampedes [OK]
Common Mistakes:
2. A high-throughput messaging system must decouple 1 million writes per second from fan-out delivery to thousands of clients. Which component best handles this decoupling to ensure durability and scalability?
easy
Solution
Step 1: Identify the decoupling requirement
Relational DB with row-level locking (Use a relational database with row-level locking to queue messages) cannot handle 1M writes/sec due to locking and durability overhead. Redis (Use Redis as an in-memory queue with TTL for message expiration) lacks durability guarantees and TTL causes message loss risk. Direct synchronous calls (Use direct synchronous HTTP calls from sender to all recipients) block sender and don't scale.Step 2: Evaluate Kafka's suitability
Kafka partitions by conversation ID ensure ordering and durability, enabling scalable fan-out with consumer groups.Final Answer:
Option A -> Option AQuick Check:
Kafka partitions -> durable, scalable decoupling [check]
Hint: Distributed logs decouple writes and fan-out reliably [check]
Common Mistakes:
3. In a Count-Min Sketch system, at step 3 the Update Worker hashes an incoming event key with the second hash function. What happens to the corresponding counter in the sketch at this step?
easy
Solution
Step 1: Understand Update Worker hashing
Each hash function maps the event key to an index in the sketch array.Step 2: Increment counter at hashed index
The Count-Min Sketch increments the counter at that index to record the event occurrence.Final Answer:
Option B -> Option BQuick Check:
Update increments counters at hash indices to track frequencies [check]
Hint: Update increments counters at hash indices, never resets or decrements [check]
Common Mistakes:
4. A system requires handling 1 million writes per second with guaranteed durability and ordered processing per user session. Which database technology best fits this requirement?
easy
Solution
Step 1: Identify ordering and durability needs
Relational DBs with row-level locking can't handle 1M writes/sec efficiently; Redis without persistence loses durability; NoSQL eventual consistency lacks ordering guarantees.Step 2: Recognize Kafka's partitioning for ordering
Kafka partitions by user session ensure ordered processing and durability at high throughput.Final Answer:
Option A -> Option AQuick Check:
Kafka partitions -> ordered, durable, high-throughput writes [check]
Hint: Kafka partitions preserve order and durability at scale [check]
Common Mistakes:
5. A large-scale key-value store needs to quickly filter out non-existent keys before querying a slow backend database. Which component best handles this filtering to reduce backend load?
easy
Solution
Step 1: Identify the filtering requirement
The system needs a fast, memory-efficient way to filter out keys that definitely do not exist before hitting the slow backend.Step 2: Evaluate component suitability
Redis cache storing all keys (A) is expensive and not scalable for huge key sets. Relational DB indexes (C) still require backend queries. Consistent hashing (D) routes keys but does not filter non-existent keys. Bloom filters (B) provide fast probabilistic membership tests with low memory.Final Answer:
Option A -> Option AQuick Check:
Bloom filters reduce backend queries by filtering non-existent keys [check]
Hint: Bloom filters quickly say no before expensive lookups [check]
Common Mistakes:
