Practice
1. A distributed task scheduler must support millions of scheduled jobs with varying priorities and ensure tasks are executed exactly once. Which component is best suited to manage task ordering and priority under these constraints?
easy
Solution
Step 1: Identify priority and scale requirements
A relational DB (A) struggles with high write throughput and priority ordering at scale; simple FIFO queues (C) lack priority support; cron jobs (D) do not coordinate distributed execution or priority.Step 2: Evaluate distributed priority queue
A distributed priority queue with partitioned shards (B) can scale horizontally, maintain priority ordering per shard, and support exactly-once execution semantics.Final Answer:
Option A -> Option AQuick Check:
Distributed priority queue shards scale and preserve ordering [check]
Hint: Distributed priority queues scale and order tasks by priority [check]
Common Mistakes:
2. Without the seat lock expiration mechanism, what exact failure occurs during concurrent bookings?
medium
Solution
Step 1: Understand role of seat lock expiration
Expiration releases seats if payment or booking is abandoned, preventing indefinite holds.Step 2: Trace failure without expiration
Locks never expire, so seats remain reserved even if users abandon payment, reducing available seats and causing booking stalls.Final Answer:
Option B -> Option BQuick Check:
No TTL -> stale locks -> seats unavailable indefinitely [check]
Hint: No expiration -> stale locks -> seats blocked forever [OK]
Common Mistakes:
3. For a payment API that must guarantee exactly-once processing despite client retries, which architecture best balances consistency and performance?
medium
Solution
Step 1: Evaluate consistency needs
Exactly-once processing requires strong consistency on idempotency keys to prevent duplicates during retries.Step 2: Compare architectures
Distributed cache with eventual consistency risks duplicates; client-only IDs lack server enforcement; async reconciliation delays correctness.Final Answer:
Option A -> Option AQuick Check:
Strongly consistent idempotency store ensures exactly-once processing [check]
Hint: Strong consistency needed for exactly-once idempotency [check]
Common Mistakes:
4. At 10x scale, which component in a cache stampede prevention system is most likely to fail first, and why?
hard
Solution
Step 1: Identify bottlenecks at 10x scale
Backend and cache scale horizontally; load balancers scale well.Step 2: Analyze distributed lock service
Lock service faces increased contention and coordination overhead, causing latency and failures.Final Answer:
Option C -> Option CQuick Check:
Distributed lock service bottlenecks first due to coordination overhead [check]
Hint: Lock service bottlenecks first due to exponential coordination overhead [OK]
Common Mistakes:
5. At 10x scale, which component in the proximity service is most likely to fail first and why?
hard
Solution
Step 1: Analyze component scalability
Databases (The database because it cannot handle the increased write throughput for location updates) can be sharded and scaled horizontally; API gateways (The API gateway because it cannot maintain the increased number of open WebSocket connections) typically scale with load balancers.Step 2: Identify Quadtree bottleneck
Quadtree's recursive traversal is CPU-intensive and stateful, making it hard to parallelize and shard, causing CPU bottlenecks under high query concurrency.Step 3: Evaluate Geohash index load
Geohash buckets (The Geohash prefix index because its fixed-length buckets cause uneven load and hotspotting) can cause hotspots but are easier to shard and cache than Quadtree traversal.Final Answer:
Option A -> Option AQuick Check:
Quadtree traversal CPU bottleneck limits scale first [check]
Hint: Quadtree traversal CPU bottleneck limits scale first [check]
Common Mistakes:
