Practice
1. During a flash sale, the system must handle sudden bursts of 10x traffic within 60 seconds, ensuring order preservation of purchase requests per user session. Which component best handles this requirement?
easy
Solution
Step 1: Identify ordering requirement per user session
Kafka partitions keyed by user session ID guarantee ordering within that partition, ensuring requests are processed sequentially per user.Step 2: Evaluate alternatives
Relational DB row-level locking (A) causes high contention and poor scalability under 10x burst. Redis (C) lacks strong ordering guarantees and durability. Load balancer (D) only distributes load but does not preserve order.Final Answer:
Option C -> Option CQuick Check:
Kafka partition key -> per-session ordering guaranteed [check]
Hint: Kafka partitions preserve order per key [check]
Common Mistakes:
2. A high-throughput web service must handle millions of requests per second with minimal latency and no session affinity. Which architectural component best supports this requirement?
easy
Solution
Step 1: Identify stateless server benefits
Stateless servers allow horizontal scaling without session affinity, reducing latency and complexity.Step 2: Evaluate session management
External session storage decouples session state from servers, enabling load balancer to distribute requests evenly.Final Answer:
Option B -> Option BQuick Check:
Stateless servers + external session store -> scalable, low-latency [check]
Hint: Stateless servers + external session store scale best [check]
Common Mistakes:
3. In a relational database transaction flow, at Step 4 the transaction manager checks the lock table before committing. What happens if the lock is held by another transaction at this step?
easy
Solution
Step 1: Understand lock table role at Step 4
The transaction manager uses the lock table to ensure no conflicting writes before commit.Step 2: Behavior on lock contention
If the lock is held, the transaction manager blocks to maintain serializability, waiting or timing out rather than aborting immediately or skipping checks.Final Answer:
Option B -> Option BQuick Check:
Lock contention causes blocking until release or timeout [check]
Hint: Lock held -> transaction blocks, no skipping or immediate abort [check]
Common Mistakes:
4. If the Kafka cluster used for fan-out events crashes and loses the latest messages, what exactly breaks in the newsfeed delivery?
medium
Solution
Step 1: Understand Kafka's role in fan-out
Kafka buffers fan-out events; Delivery Workers consume from Kafka to deliver posts asynchronously.Step 2: Trace failure impact
If Kafka crashes and loses messages, Delivery Workers waiting on those messages block or stall, causing delivery delays.Step 3: Eliminate other options
Duplicates (A) occur with retries, not loss. Lost posts (B) happen but are not the immediate failure mode. Fallback to synchronous push (D) is not automatic.Final Answer:
Option D -> Option DQuick Check:
Kafka crash causes Delivery Workers to block waiting for lost messages [check]
Hint: Kafka crash blocks Delivery Workers waiting for messages [check]
Common Mistakes:
5. At 10x scale, which component in the recommendation system is most likely to fail first due to stateful connection limits, and why?
hard
Solution
Step 1: Identify bottleneck at 10x scale
Kafka partitions limit throughput; increasing partitions is complex and causes rebalancing overhead.Step 2: Evaluate other components
Embedding DB (A) can shard by user ID; API servers (C) are typically stateless or use external session stores; embedding service caches (D) can be evicted or sharded. Kafka's partition limit causes producer backpressure and stalls event flow first.Final Answer:
Option A -> Option AQuick Check:
Kafka partition limit -> throughput bottleneck -> backpressure [check]
Hint: Kafka partitions limit throughput first at scale [check]
Common Mistakes:
