Practice
1. A distributed database system needs to evenly distribute data across 100 shards and handle dynamic addition/removal of shards with minimal data movement. Which component is most appropriate to manage shard assignment?
easy
Solution
Step 1: Understand shard assignment requirements
Modulo hashing (Use a modulo-based hash function on the primary key to assign shards directly) causes massive remapping when shards change; centralized lookup (Assign shards based on a centralized lookup table updated on every shard change) creates a bottleneck and single point of failure; range partitioning (Use range-based partitioning with fixed key ranges per shard) can cause hotspots and uneven load.Step 2: Evaluate consistent hashing benefits
Consistent hashing with virtual nodes (Implement consistent hashing with virtual nodes to map keys to shards) evenly distributes keys and minimizes remapping when shards are added or removed, making it ideal for dynamic shard management.Final Answer:
Option B -> Option BQuick Check:
Consistent hashing minimizes shard remapping on topology changes [check]
Hint: Consistent hashing minimizes data movement on shard changes [OK]
Common Mistakes:
2. A database needs to support range queries on a large numeric column with frequent inserts and updates. Which indexing method best supports efficient range scans while maintaining balanced tree structure?
easy
Solution
Step 1: Identify index type for range queries
B-Tree indexes maintain sorted order of keys, enabling efficient range scans by traversing leaf nodes sequentially.Step 2: Eliminate other options
Hash indexes do not preserve order, so range queries require scanning all buckets. Composite indexes optimize multi-column equality but don't inherently improve single-column range scans. Bitmap indexes are efficient for low-cardinality columns, not large numeric ranges.Final Answer:
Option C -> Option CQuick Check:
B-Tree supports ordered traversal for range queries [check]
Hint: B-Tree keeps keys sorted for range queries [check]
Common Mistakes:
3. For mobile clients with intermittent connectivity, which message sync strategy is best to minimize data usage while ensuring eventual consistency?
medium
Solution
Step 1: Evaluate sync strategies for intermittent mobile connectivity
WebSocket streaming fails on unstable networks; polling wastes bandwidth; full sync is expensive.Step 2: Delta-based sync with version vectors minimizes data and ensures eventual consistency
Only changed messages are fetched, reducing data usage and handling offline periods gracefully.Final Answer:
Option A -> Option AQuick Check:
Delta sync + version vectors -> efficient, consistent mobile sync [check]
Hint: Delta sync with version vectors minimizes mobile data use [OK]
Common Mistakes:
4. At 10x scale, which component of the Snowflake ID generation system is most likely to become the bottleneck first, and why?
hard
Solution
Step 1: Analyze timestamp and network constraints
Timestamp synchronization (A) is challenging but tolerable with NTP; network coordination (D) is minimal as IDs are generated locally.Step 2: Evaluate sequence number limits
Sequence number (B) limits per millisecond can cause blocking but can be mitigated by load balancing or sharding.Step 3: Identify machine ID allocation bottleneck
Machine ID bits are fixed (e.g., 10 bits), limiting the number of unique machines. At 10x scale, running out of unique machine IDs causes collisions or requires complex reallocation.Final Answer:
Option D -> Option DQuick Check:
Fixed machine ID bits limit scale -> collisions or reconfiguration needed [check]
Hint: Fixed machine ID bits limit scale before sequence or timestamp issues [OK]
Common Mistakes:
5. At 10x traffic scale, which component in a CDN-backed architecture is most likely to fail first and why?
hard
Solution
Step 1: Analyze CDN edge server cache storage limits
At 10x scale, edge caches may evict content more frequently, increasing origin fetches.Step 2: Recognize increased origin fetches overload origin servers but edge cache misses spike first
Edge servers become bottlenecks due to cache capacity and eviction policies before origin overload.Final Answer:
Option C -> Option CQuick Check:
Edge cache storage limits cause first failure at scale, not origin or load balancers [check]
Hint: Edge cache storage limits cause origin fetch spikes first at scale [OK]
Common Mistakes:
