Practice
Solution
Step 1: Identify query pattern
Friend-of-friend queries require efficient traversal of relationships, which relational JOINs or document stores handle poorly at scale.Step 2: Match technology to pattern
Graph databases optimize relationship traversal with index-free adjacency, enabling low-latency queries on connected data.Final Answer:
Option C -> Option CQuick Check:
Graph DBs excel at relationship traversal, unlike wide-column or document stores [check]
Solution
Step 1: Analyze ordering and fault tolerance requirements
Redis single instance (A) is a single point of failure and limited in scale. Relational DB (C) has high latency and limited throughput for 1M+ messages. Distributed cache with eventual consistency (D) cannot guarantee ordering.Step 2: Evaluate Kafka's partitioning and consumer groups
Kafka partitions by conversation ID ensure ordering per conversation. Consumer groups allow scalable processing with fault tolerance. Kafka replicates partitions for node failure tolerance.Final Answer:
Option C -> Option CQuick Check:
Kafka partitions + consumer groups -> ordering + fault tolerance [check]
Solution
Step 1: Identify role of event queue
The event queue asynchronously propagates updates to read replicas.Step 2: Trace failure impact
If the queue fails, read replicas stop receiving updates and serve stale data indefinitely.Final Answer:
Option B -> Option BQuick Check:
Queue failure causes stale reads, no automatic failover [check]
Solution
Step 1: Identify bottleneck in distributed updates
Centralized coordinator serializes updates to maintain consistency, limiting throughput.Step 2: Analyze other components
Network bandwidth and hash function speed scale better; sketch arrays have fixed size but don't overflow.Step 3: Understand scale impact
At 10x scale, coordinator becomes overwhelmed, causing update latency and failures.Final Answer:
Option D -> Option DQuick Check:
Central coordinator serialization bottlenecks updates at scale [check]
Solution
Step 1: Identify bottlenecks at 10x scale
Distributed lock service coordinates exclusive access and must handle many concurrent lock requests.Step 2: Evaluate component scalability
Relational DB (The relational database because it cannot handle the increased write throughput for reservations) can be scaled with sharding and read replicas. Inventory Service caches (The Inventory Service because it maintains stateful caches that cannot be sharded easily) can be sharded or invalidated. API Gateway (The API Gateway because it cannot route the increased number of client requests efficiently) can be horizontally scaled with load balancers. The lock service (The distributed lock service because it becomes a bottleneck coordinating locks across many nodes) is a centralized coordination point and becomes a bottleneck due to synchronization overhead and network latency.Final Answer:
Option A -> Option AQuick Check:
Distributed lock service bottlenecks first due to coordination overhead [check]
