Practice
Solution
Step 1: Identify decoupling need
High write rate (10,000/sec) requires asynchronous processing to avoid blocking user requests.Step 2: Evaluate components
Relational DB synchronous writes (A) block requests; Redis (B) lacks durability guarantees for event buffering; batch jobs (C) are too infrequent for real-time updates. Kafka (D) buffers events reliably and supports asynchronous consumption.Final Answer:
Option C -> Option CQuick Check:
Kafka buffers high write throughput asynchronously [check]
Solution
Step 1: Identify NAT traversal role
STUN/TURN servers help clients discover public IPs and relay media if direct peer-to-peer fails.Step 2: Eliminate other components
Media Server relays media but is not primarily for NAT traversal; Signaling Server handles session negotiation, not media encoding; WebRTC client manages connection but relies on STUN/TURN for NAT traversal.Final Answer:
Option A -> Option AQuick Check:
STUN/TURN enable NAT traversal, essential for peer connectivity [check]
Solution
Step 1: Identify write throughput and query pattern
The system requires high write throughput and efficient retrieval by user and timestamp, which suits wide-column stores that partition data by user ID.Step 2: Evaluate options against constraints
Relational DBs struggle with high write throughput and joins; document stores lack efficient range queries by timestamp; Redis lacks durability and is not ideal for large persistent datasets.Final Answer:
Option A -> Option AQuick Check:
Wide-column store partitions by user ID -> high write throughput and efficient user queries [check]
Solution
Step 1: Evaluate centralized generator with sync replication
This causes high latency and single point of failure, unsuitable for geo-distributed low-latency needs.Step 2: Assess decentralized Snowflake approach
Decentralized generators with node IDs and loosely synchronized clocks provide low latency and uniqueness with approximate ordering.Step 3: Consider UUID v4 and DB auto-increment
UUID v4 lacks ordering; DB auto-increment with partitioning risks collisions and coordination overhead.Final Answer:
Option B -> Option BQuick Check:
Decentralized Snowflake -> low latency + uniqueness + approximate ordering [check]
Solution
Step 1: Analyze bottlenecks at 10x scale
Database (A) can be sharded; cache (C) scales horizontally; Kafka (D) can add partitions but has limits.Step 2: Delivery Workers face exponential fan-out growth
Fan-out queues grow with followers; Delivery Workers must push updates to millions more followers, causing processing lag and backlog.Final Answer:
Option B -> Option BQuick Check:
Delivery Workers bottleneck due to fan-out processing load [check]
