Practice
Solution
Step 1: Analyze read/write pattern for restaurant discovery
High read volume with frequent writes requires low-latency reads and near-real-time updates.Step 2: Evaluate architectures
Relational DB (A) can't handle query volume with low latency; batch ETL (C) is too stale; client filtering (D) is impractical for large data.Final Answer:
Option B -> Option BQuick Check:
Distributed cache with async sync -> low latency + fresh data [check]
Solution
Step 1: Analyze architecture trade-offs
Synchronous two-phase commit (Use a synchronous two-phase commit protocol across all services to guarantee atomicity) blocks and reduces throughput; centralized DB (Use a centralized relational database with serializable transactions for all payment states) limits scalability; client-side retries (Use client-side retries with unique request IDs and eventual consistency in backend) risk inconsistent states.Step 2: Evaluate event-driven approach
Kafka event sourcing with idempotent consumers supports high throughput, fault tolerance, and exactly-once processing semantics.Final Answer:
Option A -> Option AQuick Check:
Kafka event sourcing -> scalable, fault-tolerant, idempotent processing [check]
Solution
Step 1: Analyze client connectivity constraints
Mobile clients often have intermittent connectivity and poor support for HTTP/2 streaming.Step 2: Evaluate streaming options
Direct gRPC streaming (A) is unreliable on mobile. WebSockets (C) add complexity and JSON is less efficient. REST long polling (D) is less efficient and higher latency. Unary calls with polling and backoff (B) handle intermittent connectivity gracefully.Final Answer:
Option B -> Option BQuick Check:
Mobile intermittent -> unary calls + polling with backoff [check]
Solution
Step 1: Understand failure impact on error budget updates
If aggregation service fails partially, inconsistent error counts across nodes cause alerting to behave erratically.Step 2: Eliminate other failure modes
Resetting to zero (A) is unlikely without explicit reset; no alerts (B) implies total failure, not partial inconsistency; delayed alerts (D) imply buffering, not aggregation failure.Final Answer:
Option A -> Option AQuick Check:
Aggregation failure -> inconsistent counts -> random alert triggers [check]
Solution
Step 1: Understand lack of distributed locking
Without distributed locks, concurrent updates can overwrite each other silently (B), causing inconsistent state.Step 2: Evaluate other options
System does not automatically queue updates (C) without explicit coordination. Database rejecting conflicting transactions (D) depends on isolation level and may not prevent lost updates. System crash (A) is unrelated.Final Answer:
Option C -> Option CQuick Check:
Concurrent updates without locks -> silent overwrite [check]
