Practice
1. A web application needs to ensure that cache entries are updated immediately after every write to the database to prevent stale reads. Which caching pattern best fits this requirement?
easy
Solution
Step 1: Identify cache update timing
Write-Through updates cache and database synchronously, ensuring cache is always fresh.Step 2: Eliminate other patterns
Cache Aside updates cache only on misses, risking stale cache after writes; Read-Through only loads on reads; Write-Behind delays DB update, risking stale cache.Final Answer:
Option B -> Option BQuick Check:
Write-Through synchronously updates cache and DB [check]
Hint: Write-Through syncs cache and DB on writes [check]
Common Mistakes:
2. A distributed system needs to generate unique IDs for millions of events per second without coordination delays. Which component is best suited to generate these IDs efficiently?
easy
Solution
Step 1: Identify coordination bottlenecks in centralized DB
Auto-increment keys require coordination, causing latency and contention at high scale.Step 2: Evaluate decentralized timestamp-based ID generators
Snowflake-style IDs combine timestamp and node ID, enabling scalable, ordered unique IDs without coordination.Final Answer:
Option A -> Option AQuick Check:
Decentralized timestamp + node ID -> scalable unique ID generation [check]
Hint: Decentralized timestamp + node ID avoids coordination delays [check]
Common Mistakes:
3. If the recursive DNS server's cache is completely disabled, what is the most immediate failure mode experienced by users during domain resolution?
medium
Solution
Step 1: Understand recursive server caching role
The recursive DNS server cache reduces query latency by storing recent results. Without caching, every query requires a full resolution chain traversal.Step 2: Trace failure impact
Without cache, recursive server must synchronously query authoritative servers for every request, causing increased latency and possible timeouts, blocking user queries.Final Answer:
Option D -> Option DQuick Check:
No cache -> synchronous queries -> high latency and blocking [check]
Hint: No cache means blocking queries until authoritative response [check]
Common Mistakes:
4. For a global typeahead autocomplete service that must support fuzzy matching and ranking by popularity, which architecture is best suited?
medium
Solution
Step 1: Evaluate fuzzy matching and ranking requirements
Fuzzy matching and popularity ranking require complex scoring and typo tolerance, which Elasticsearch supports natively with fuzzy queries and custom scoring functions.Step 2: Assess other options
Trie and prefix hash map lack built-in fuzzy matching and ranking; relational DB LIKE queries are inefficient and don't scale well for fuzzy search.Final Answer:
Option A -> Option AQuick Check:
Elasticsearch supports fuzzy search and ranking out-of-the-box [check]
Hint: Elasticsearch = fuzzy + ranking built-in [check]
Common Mistakes:
5. At 10x scale, which component is most likely to fail first and why in Slack's real-time delivery system?
hard
Solution
Step 1: Identify stateful bottlenecks at scale
Chat servers hold WebSocket connections in memory, which are stateful and tied to specific servers, limiting horizontal scaling.Step 2: Compare other components
Databases can be sharded; Kafka scales with partitions; presence service caches can be distributed; chat servers' stateful connections are the hardest to shard.Final Answer:
Option A -> Option AQuick Check:
Stateful WebSocket connections -> chat servers bottleneck at 10x scale [check]
Hint: Stateful WebSocket binds chat servers -> first bottleneck [check]
Common Mistakes:
