Practice
Solution
Step 1: Identify asynchronous progress update requirement
Relational DB synchronous writes (Use a relational database with synchronous writes on every video event) block video playback and don't scale well for millions of concurrent updates.Step 2: Evaluate buffering and decoupling
Message queue (Use a message queue to buffer progress update events for asynchronous processing) decouples video playback from progress persistence, enabling scalable asynchronous processing.Final Answer:
Option A -> Option AQuick Check:
Message queue buffers progress updates for async processing [check]
Solution
Step 1: Analyze follower distribution impact on fan-out
Fan-out on write for users with millions of followers causes huge write amplification and storage overhead. Fan-out on read for low-follower users increases read latency unnecessarily.Step 2: Evaluate hybrid approach benefits
Hybrid approach balances write amplification and read latency by applying fan-out on write only where follower count is manageable, and fan-out on read for heavy hitters.Final Answer:
Option A -> Option AQuick Check:
Hybrid fan-out balances write cost and read latency [check]
Solution
Step 1: Evaluate encryption approaches for read latency and security
TDE with HSMs provides strong security with minimal impact on read latency as encryption/decryption is transparent and hardware-accelerated.Step 2: Eliminate less suitable options
Client-side encryption increases latency and complicates querying; app-layer encryption with env vars risks key exposure and adds latency; file system encryption protects at disk level but not granular data access.Final Answer:
Option B -> Option BQuick Check:
TDE + HSM balances security and low-latency reads [check]
Solution
Step 1: Analyze stateful components at scale
Chat servers maintain WebSocket connections statefully; scaling requires connection migration or sticky sessions.Step 2: Identify bottleneck
At 10x scale, chat servers hit connection limits and cannot shard existing connections, causing failure before DB or load balancer.Final Answer:
Option C -> Option CQuick Check:
Stateful WebSocket servers -> scaling bottleneck due to connection affinity [check]
Solution
Step 1: Identify stateful components in WebSocket architecture
WebSocket connections are stateful and maintained in server memory, binding clients to specific chat servers.Step 2: Analyze scaling challenges
At 10x scale, chat servers face difficulty resharding connections or migrating them, limiting horizontal scaling. Databases and load balancers can be scaled more easily. Client browser limits are less impactful at system scale.Final Answer:
Option A -> Option AQuick Check:
WebSocket stateful connections -> chat servers bottleneck at scale [check]
