Practice
1. In the newsfeed system, at Step 4 the Delivery Worker reads a fan-out event from Kafka and attempts to deliver it to followers. What happens if a follower's device is offline at this step?
easy
Solution
Step 1: Trace Delivery Worker behavior at Step 4
The Delivery Worker reads fan-out events from Kafka and attempts delivery. If the follower is offline, immediate retry (A) would block and reduce throughput. Dropping messages (C) causes data loss. Pushing directly to device cache (D) is impossible if offline.Step 2: Understand retry mechanism
The system marks the message as sent but not delivered, queues it for retry later when the follower reconnects, ensuring eventual delivery without blocking.Final Answer:
Option A -> Option AQuick Check:
Offline followers cause queued retries, not immediate blocking [check]
Hint: Offline followers cause queued retries, not immediate blocking [check]
Common Mistakes:
2. A typeahead system must handle millions of concurrent prefix queries with low latency and high throughput. Which component is best suited to serve these prefix lookups efficiently at scale?
easy
Solution
Step 1: Identify prefix lookup requirements
Prefix queries require fast, low-latency lookups optimized for string prefixes, which relational DB LIKE queries are inefficient at scale.Step 2: Evaluate component suitability
A distributed in-memory Trie cache supports efficient prefix matching and can be sharded by prefix hash for scalability, unlike message queues or full-text search without caching.Final Answer:
Option A -> Option AQuick Check:
Distributed Trie cache -> efficient prefix lookups at scale [check]
Hint: Trie caches excel at prefix queries, unlike DB LIKE or queues [check]
Common Mistakes:
3. A distributed system needs to generate unique 64-bit IDs that are sortable by creation time and avoid collisions across multiple data centers without central coordination. Which component design best fits this requirement?
easy
Solution
Step 1: Identify uniqueness and ordering requirements
The system requires unique 64-bit IDs sortable by creation time and no central coordination to avoid bottlenecks.Step 2: Evaluate options against constraints
UUID v4 (A) is random and not sortable; centralized DB (C) creates a bottleneck; hashing timestamp and IP (D) risks collisions and no strict ordering. Snowflake (B) combines timestamp, machine ID, and sequence to ensure uniqueness and time ordering without central coordination.Final Answer:
Option C -> Option CQuick Check:
Snowflake IDs are time-sortable and unique across machines [check]
Hint: Timestamp + machine ID + sequence ensures unique sortable IDs [OK]
Common Mistakes:
4. If the Kafka cluster responsible for vote event streaming goes down, what exactly breaks in the Reddit voting system?
medium
Solution
Step 1: Understand Kafka's role in buffering vote events
Kafka buffers vote events reliably; if it fails, vote events cannot be streamed to processors.Step 2: Analyze failure impact
Vote submissions do not block immediately (Vote events cannot be buffered, causing vote submission requests to block or fail immediately wrong) because frontends can still accept votes and cache temporarily. Votes are not lost silently (Users can still vote, but votes are lost silently without any retry wrong) because Redis or other caches buffer them. UI shows stale scores due to lack of processed updates (The UI shows stale post scores but votes are queued in Redis for later processing correct). Votes continue to be processed but ranking updates become inconsistent is incorrect as votes stop flowing, not just ranking inconsistency.Final Answer:
Option B -> Option BQuick Check:
Kafka failure causes stale UI scores; votes buffered in Redis [check]
Hint: Kafka down -> stale UI, votes buffered temporarily [check]
Common Mistakes:
5. For a high-throughput e-commerce platform requiring sortable, unique order IDs generated across multiple regions with minimal coordination, which ID generation approach is best?
medium
Solution
Step 1: Identify requirements
High throughput, sortable, unique IDs across regions with minimal coordination.Step 2: Evaluate options
UUIDv4 (A) is unique but not sortable; centralized auto-increment (C) causes bottlenecks; independent auto-increment (D) risks collisions; Snowflake-style IDs (B) embed timestamp and region, enabling sortable, unique IDs with decentralized generation.Final Answer:
Option A -> Option AQuick Check:
Snowflake IDs -> sortable, unique, decentralized [check]
Hint: Sortable unique IDs at scale -> Snowflake pattern [check]
Common Mistakes:
