Practice
Solution
Step 1: Identify consistency and latency requirements
Strong consistency requires synchronous replication; low latency demands minimal delay.Step 2: Evaluate architecture options
Single primary DB with sync replication ensures consistency but may increase latency slightly; best trade-off.Final Answer:
Option B -> Option BQuick Check:
Synchronous replication balances strong consistency and latency [check]
Solution
Step 1: Identify Write-Through bottleneck
Write-Through synchronously writes to DB on every write, increasing DB load linearly with scale.Step 2: Compare other components
Cache handles fast reads; network bandwidth usually sufficient; app servers block but DB saturation causes overall failure first.Final Answer:
Option C -> Option CQuick Check:
DB synchronous writes bottleneck Write-Through at scale [check]
Solution
Step 1: Analyze component scalability
Search clusters (A) scale horizontally with sharding; Kafka (C) can increase partitions; user DB (D) can be sharded or use multi-master.Step 2: Stateful feed generation bottleneck
Feed generation maintains per-user session caches and WebSocket connections, which are stateful and tied to specific servers, limiting horizontal scaling and causing early failure.Final Answer:
Option C -> Option CQuick Check:
Stateful feed caches block horizontal scaling, causing first failure [check]
Solution
Step 1: Identify idempotency store workload at scale
Idempotency store must synchronously write and read keys with strong consistency, creating a high throughput bottleneck.Step 2: Compare other components
Payment processors can be scaled horizontally; API gateways are stateless and scalable; client SDKs generating keys is lightweight.Final Answer:
Option D -> Option DQuick Check:
Synchronous idempotency store writes limit scaling first [check]
Solution
Step 1: Analyze stateful components and scaling challenges
Databases (The database, because increased writes cause lock contention) can be scaled with sharding and replicas. Message queue brokers (The message queue brokers, due to partition leader overload) scale horizontally with partitions. Delivery workers (The delivery workers, because retry queues grow exponentially) can be scaled with backpressure.Step 2: Identify chat servers as stateful WebSocket connection holders
Chat servers maintain persistent WebSocket connections bound to server memory, making resharding or migration difficult at scale.Final Answer:
Option C -> Option CQuick Check:
Stateful WebSocket servers -> first bottleneck at 10x scale [check]
