Practice
Solution
Step 1: Identify Kafka's role in event sourcing
Kafka supports high throughput with partitioning by aggregate ID, ensuring ordered event processing per aggregate.Step 2: Evaluate other options
Redis pub/sub lacks durability guarantees; relational DB triggers don't scale to 1M events/sec; RabbitMQ's round-robin breaks ordering per aggregate.Final Answer:
Option B -> Option BQuick Check:
Kafka partitions by aggregate ID -> ordered, durable event stream [check]
Solution
Step 1: Evaluate synchronous retries (A)
Retries increase latency and risk cascading failures, bad for mobile responsiveness.Step 2: Compare asynchronous queue (C) and caching (D)
Queues add delay and complexity; caching avoids calls but may serve stale data, not ideal for dynamic data.Step 3: Circuit breaker with short timeout and fallback (B)
Provides quick failure detection, prevents cascading failures, and returns fallback to maintain responsiveness.Final Answer:
Option C -> Option CQuick Check:
Circuit breaker with fallback balances isolation and responsiveness [check]
Solution
Step 1: Trace failure impact on write path
Without Kafka, writes accepted locally but not durably logged can be lost if the server crashes before Kafka recovers.Step 2: Eliminate other options
The system falls back to eventual consistency, causing stale reads temporarily is incorrect because fallback to eventual consistency is not automatic; The client's write blocks indefinitely until Kafka recovers, preventing data loss is wrong because writes may not block indefinitely; The system switches to causal consistency mode automatically to maintain availability is false as consistency mode does not switch automatically.Final Answer:
Option C -> Option CQuick Check:
Writes accepted locally but lost if server crashes before Kafka recovers [check]
Solution
Step 1: Understand Kafka unavailability impact
Without Kafka, ingestion of new document updates cannot proceed, causing blocking or stalling.Step 2: Evaluate options
Indexing workers do not have local caches of events (A) and cannot continue processing. Automatic failover to a backup queue with identical ordering (C) is a designed mitigation. Index corruption (D) does not happen immediately; missing events cause stale results but not corruption.Final Answer:
Option A -> Option AQuick Check:
Failover to backup queue prevents pipeline stall [check]
Solution
Step 1: Understand HyperLogLog state loss impact
Losing the register state means the approximate count for that shard is lost; no exact user IDs are stored elsewhere.Step 2: Check consequences on cardinality
Without the register, the system cannot include that shard's data, causing undercounting, not overcounting or exact counts.Final Answer:
Option A -> Option AQuick Check:
Lost registers -> missing data -> undercounting unique users [check]
