Practice
1. A web application experiences increasing CPU load on a single database server, causing query latency spikes. Which scaling approach best addresses this bottleneck without changing the application code?
easy
Solution
Step 1: Identify the bottleneck as CPU and memory on a single DB server
Vertical scaling adds resources to the existing server to handle more load without architectural changes.Step 2: Evaluate horizontal scaling and other options
Horizontal scaling requires application changes for sharding; caching reduces reads but not CPU-bound writes; switching DB types is a different trade-off.Final Answer:
Option B -> Option BQuick Check:
Vertical scaling adds resources to one server without code changes [check]
Hint: Vertical scaling adds power to one machine [check]
Common Mistakes:
2. In the unique ID generation system, at step 3 the ID generator node receives a timestamp and node ID. What state does the generator maintain to ensure uniqueness when the timestamp is the same as the previous request?
easy
Solution
Step 1: Understand sequence number reset behavior
For each new timestamp, the sequence number resets to zero to start fresh counting.Step 2: Ensure uniqueness within timestamp by incrementing sequence
Within the same timestamp, the sequence number increments; resetting happens only when timestamp changes.Final Answer:
Option A -> Option AQuick Check:
Sequence number resets on new timestamp -> uniqueness maintained [check]
Hint: Sequence number resets to zero on new timestamp [check]
Common Mistakes:
3. For a pub-sub system requiring low latency fan-out to millions of subscribers with dynamic topic subscriptions, which architecture is best suited?
medium
Solution
Step 1: Evaluate synchronous push and multicast
Centralized synchronous push (Use a centralized broker that pushes messages directly to all subscribers synchronously) causes bottlenecks and backpressure. Multicast (Use a multicast network protocol to broadcast messages to all subscribers) lacks reliability and fine-grained subscription control.Step 2: Assess polling and distributed log
Polling (Use a polling-based system where subscribers fetch messages periodically from a database) adds latency and load. Distributed log with partitions and consumer groups (Use a distributed log system with topic partitions and consumer groups for parallel consumption) supports scalable, parallel, and dynamic subscriptions with low latency.Final Answer:
Option D -> Option DQuick Check:
Distributed logs scale fan-out with parallel consumers [check]
Hint: Distributed logs + consumer groups = scalable low-latency fan-out [check]
Common Mistakes:
4. Without the Rendezvous Hashing component in a distributed cache, what exactly breaks when a node fails?
medium
Solution
Step 1: Understand role of Rendezvous Hashing in failure
Rendezvous Hashing provides deterministic mapping without central coordination. Without it, no automatic remapping occurs.Step 2: Trace failure impact
Without Rendezvous Hashing, system blocks or requires manual remapping, causing request blocking and downtime.Final Answer:
Option B -> Option BQuick Check:
No automatic remapping -> system blocks until manual config [check]
Hint: No Rendezvous -> manual remap blocks requests [check]
Common Mistakes:
5. At 10x scale, which component is most likely to fail first and why in Facebook Messenger's group chat system?
hard
Solution
Step 1: Analyze stateful components at 10x scale
Chat Servers maintain WebSocket connections bound to server memory, limiting horizontal scaling.Step 2: Compare other components
Databases and Kafka can be sharded or scaled; Redis TTL issues cause transient problems but not first failure.Final Answer:
Option A -> Option AQuick Check:
Stateful WebSocket connections -> Chat Servers bottleneck at scale [check]
Hint: Stateful WebSocket binds connections -> Chat Servers bottleneck [OK]
Common Mistakes:
