Practice
1. A social media platform must handle 1 million tweet writes per second and fan-out to millions of followers asynchronously. Which component best decouples tweet ingestion from timeline delivery to ensure durability and scalability?
easy
Solution
Step 1: Identify the role of the distributed log
Kafka partitions by user ID to preserve ordering and durability, decoupling ingestion from delivery.Step 2: Eliminate other options
Relational DB triggers (A) cause synchronous blocking and don't scale; Redis (C) lacks durability and persistence; synchronous RPC (D) blocks on follower availability.Final Answer:
Option B -> Option BQuick Check:
Kafka partitions ensure durable, ordered, asynchronous fan-out [check]
Hint: Distributed log decouples ingestion and delivery [check]
Common Mistakes:
2. In a distributed lock system using ZooKeeper, at step 4 the client attempts to acquire the lock by creating an ephemeral sequential node. What happens if the client crashes immediately after creating this node but before confirming lock ownership?
easy
Solution
Step 1: Understand ephemeral node semantics
Ephemeral nodes in ZooKeeper are automatically deleted when the client session ends (e.g., crash), preventing deadlocks (A) and stale locks.Step 2: Trace lock ownership after crash
Since the ephemeral node is deleted, the next client waiting for the lock will be notified, but the lock is not immediately transferred (D) until they acquire it explicitly.Final Answer:
Option A -> Option AQuick Check:
Ephemeral node deletion on client crash -> lock released [check]
Hint: Ephemeral nodes vanish on client crash, freeing locks [check]
Common Mistakes:
3. For handling concurrent seat bookings, which architecture better suits a high-traffic ticketing system requiring low latency and strong consistency?
medium
Solution
Step 1: Analyze concurrency and latency requirements
High traffic and low latency require minimizing blocking and centralized bottlenecks.Step 2: Evaluate architectures
Centralized DB serializable transactions cause contention and latency; message queue serialization adds delay; client-side locking is unreliable. Distributed cache with optimistic locking allows concurrent attempts with retries, balancing consistency and performance.Final Answer:
Option D -> Option DQuick Check:
Optimistic locking in distributed cache balances concurrency and consistency [check]
Hint: Optimistic locking + retry beats centralized locks under load [OK]
Common Mistakes:
4. For the review system, which architecture better supports real-time aggregation of review scores for millions of listings with minimal latency, given that eventual consistency is acceptable?
medium
Solution
Step 1: Identify real-time aggregation needs
Millions of listings require low-latency updates; immediate consistency is not mandatory.Step 2: Evaluate architectures
Relational DB (A) is costly and slow at scale; batch jobs (C) have high latency; NoSQL denormalization (D) risks write amplification and stale data. Stream processing (B) provides scalable, low-latency aggregation with eventual consistency.Final Answer:
Option A -> Option AQuick Check:
Stream processing enables scalable real-time aggregation with eventual consistency [check]
Hint: Stream processing fits real-time aggregation with eventual consistency [check]
Common Mistakes:
5. For the For-You feed algorithm, which architecture best balances freshness of recommendations with scalability when serving millions of users?
medium
Solution
Step 1: Evaluate synchronous recomputation
Monolithic synchronous (A) causes high latency and poor scalability.Step 2: Compare batch vs streaming
Streaming (C) offers freshness but is complex and costly at scale; client-side (D) lacks data for quality recommendations.Step 3: Select batch precompute
Batch jobs (B) balance freshness and scalability by precomputing and caching recommendations.Final Answer:
Option C -> Option CQuick Check:
Batch precompute caches recommendations for scalable freshness [check]
Hint: Batch precompute balances freshness and scale best [OK]
Common Mistakes:
