Practice
1. In a chat system, at step 4 the Delivery Worker checks Bob's presence TTL in Redis before delivering a message. What happens if Bob's presence key has expired at this step?
easy
Solution
Step 1: Trace Delivery Worker decision at Step 4 -- Bob's presence TTL
If Bob's presence key expired, it means Bob is offline. The worker should queue the message for offline delivery and mark it undelivered.Step 2: Eliminate wrong states
Delivering immediately (The Delivery Worker delivers the message immediately to Bob's device) ignores offline status. Deleting message (The Delivery Worker deletes the message assuming Bob is offline permanently) causes data loss. Retrying indefinitely (The Delivery Worker retries checking Bob's presence key indefinitely) blocks delivery pipeline.Final Answer:
Option B -> Option BQuick Check:
Expired presence -> queue for offline delivery [check]
Hint: Expired presence means offline; queue message for later [check]
Common Mistakes:
2. In a consistent hashing system, at Step 4 the request router receives a key and queries the hash ring to find the responsible shard. What happens if the shard mapped by the hash ring is currently down?
easy
Solution
Step 1: Trace request router behavior on shard failure
Retrying the same shard (The router retries the same shard until it recovers before forwarding the request) blocks requests; returning error (The router returns an error immediately to the client indicating shard unavailability) reduces availability; next clockwise shard (The router uses the next clockwise shard on the hash ring as a fallback for the key) is correct only if the ring is intact and shard failure is handled by virtual nodes.Step 2: Understand fallback hashing
Rehashing with a different function (The router hashes the key again with a different hash function to find another shard) is a common fallback to find an alternate shard when the primary is down, ensuring availability without blocking or errors.Final Answer:
Option D -> Option DQuick Check:
Fallback hashing finds alternate shard on failure [check]
Hint: Fallback hashing finds alternate shard if primary is down [OK]
Common Mistakes:
3. If the prefix hash map component fails and becomes unavailable, what is the immediate impact on the autocomplete system's behavior?
medium
Solution
Step 1: Understand component roles
The prefix hash map is an optimization for O(1) prefix lookups, but the Trie is the primary data structure for prefix matching.Step 2: Trace failure impact
If the prefix hash map fails, the system falls back to the Trie for prefix queries, which still works but may have slightly higher latency.Final Answer:
Option B -> Option BQuick Check:
Trie fallback ensures prefix queries continue despite prefix hash map failure [check]
Hint: Trie fallback keeps prefix search alive if prefix hash fails [check]
Common Mistakes:
4. At 10x scale, which component in a cache stampede prevention system is most likely to fail first, and why?
hard
Solution
Step 1: Identify bottlenecks at 10x scale
Backend and cache scale horizontally; load balancers scale well.Step 2: Analyze distributed lock service
Lock service faces increased contention and coordination overhead, causing latency and failures.Final Answer:
Option C -> Option CQuick Check:
Distributed lock service bottlenecks first due to coordination overhead [check]
Hint: Lock service bottlenecks first due to exponential coordination overhead [OK]
Common Mistakes:
5. At 10x scale, which component of a distributed Count-Min Sketch system is most likely to fail first and why?
hard
Solution
Step 1: Identify bottleneck in distributed updates
Centralized coordinator serializes updates to maintain consistency, limiting throughput.Step 2: Analyze other components
Network bandwidth and hash function speed scale better; sketch arrays have fixed size but don't overflow.Step 3: Understand scale impact
At 10x scale, coordinator becomes overwhelmed, causing update latency and failures.Final Answer:
Option D -> Option DQuick Check:
Central coordinator serialization bottlenecks updates at scale [check]
Hint: Central coordinator serializes updates, bottlenecking at scale [check]
Common Mistakes:
