Practice
Solution
Step 1: Understand key distribution needs
Simple modulo hashing (Using a simple modulo hash function on node count to assign keys) causes massive remapping when nodes change, failing graceful scaling.Step 2: Evaluate consistent hashing benefits
Consistent hashing with virtual nodes (Implementing consistent hashing with virtual nodes) minimizes remapping and balances load even with node failures.Final Answer:
Option A -> Option AQuick Check:
Consistent hashing with virtual nodes -> minimal key remapping on node changes [check]
Solution
Step 1: Identify the need to clarify trade-offs
Presenting trade-offs requires explicit comparison of conflicting requirements, such as latency vs consistency.Step 2: Use a decision matrix for clarity
A decision matrix systematically compares options, showing pros and cons clearly, which helps interviewers understand your reasoning.Final Answer:
Option A -> Option AQuick Check:
Decision matrix clarifies trade-offs explicitly [check]
Solution
Step 1: Understand WAL role in replication
WAL is the source of truth for replicas to catch up incrementally.Step 2: Trace failure impact
If WAL is lost, replicas cannot catch up incrementally and must request full snapshot, causing load and delay.Final Answer:
Option A -> Option AQuick Check:
Lost WAL -> replicas request full snapshot -> recovery delay [check]
Solution
Step 1: Understand Kafka's role in fan-out
Kafka buffers fan-out events; Delivery Workers consume from Kafka to deliver posts asynchronously.Step 2: Trace failure impact
If Kafka crashes and loses messages, Delivery Workers waiting on those messages block or stall, causing delivery delays.Step 3: Eliminate other options
Duplicates (A) occur with retries, not loss. Lost posts (B) happen but are not the immediate failure mode. Fallback to synchronous push (D) is not automatic.Final Answer:
Option D -> Option DQuick Check:
Kafka crash causes Delivery Workers to block waiting for lost messages [check]
Solution
Step 1: Evaluate batch vs real-time ranking
Batch (A) is too stale for real-time user behavior; heuristic (C) lacks adaptability; client-side (D) cannot access server-side signals securely.Step 2: Online feature store benefits
Online feature stores enable real-time scoring with fresh data and incremental model updates, supporting complex signals and spam detection.Final Answer:
Option D -> Option DQuick Check:
Online feature store supports real-time, complex ranking [check]
