Practice
Solution
Step 1: Trace Distributed Counter behavior at Step 4
The counter checks if the increment would exceed the limit; if yes, it rejects the request immediately.Step 2: Eliminate incorrect states
Allowing increment with warning (B) breaks enforcement; delaying increment (C) causes inconsistent state; forwarding (D) adds complexity and is not standard.Final Answer:
Option A -> Option AQuick Check:
Counter rejects requests exceeding limit immediately [check]
Solution
Step 1: Understand Feed Aggregator's role at Step 5
The Feed Aggregator must combine posts from multiple sources, remove duplicates, and rank them to personalize the feed.Step 2: Eliminate incorrect options
It immediately returns the raw posts without filtering or ranking skips ranking, leading to poor UX. It stores all posts in a persistent database before responding to the user delays response unnecessarily. It sends posts to the notification service to alert the user before aggregation misplaces notification logic before feed aggregation.Final Answer:
Option A -> Option AQuick Check:
Feed Aggregator merges and ranks posts -> personalized feed [check]
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: Trace client lock acquisition at Step 4
Redlock requires majority of Redis masters to be locked within timeout to consider lock acquired.Step 2: Handle partial lock acquisition
If fewer than majority locks acquired, client must release any partial locks to avoid deadlocks and retry.Final Answer:
Option B -> Option BQuick Check:
Partial lock acquisition -> release all and retry [check]
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]
