Practice
Solution
Step 1: Identify the need for deduplication and exactly-once semantics
Duplicate callbacks require idempotent processing and event tracking to avoid double charges.Step 2: Evaluate event sourcing with idempotent handlers
Event sourcing stores all events immutably with unique IDs, enabling replay and deduplication.Final Answer:
Option A -> Option AQuick Check:
Event sourcing with idempotent handlers ensures exactly-once processing [check]
Solution
Step 1: Understand Kafka's role in event streaming
Kafka streams photo upload events to downstream processors like metadata extraction and feed generation.Step 2: Trace failure impact
If Kafka is down, photo uploads still succeed because upload service writes to storage directly. Feed generation depends on Kafka events for stories update; without Kafka, stories updates stop, but feed generation for photos continues from DB. Metadata extraction is delayed but not necessarily indefinite. Notifications are handled separately.Final Answer:
Option B -> Option BQuick Check:
Kafka outage stops stories update but feed photo generation continues [check]
Solution
Step 1: Analyze team size and feature velocity constraints
Small teams benefit from simpler architectures to reduce overhead and speed delivery.Step 2: Evaluate operational complexity of microservices
Microservices add deployment and operational complexity, which can slow small teams.Final Answer:
Option B -> Option BQuick Check:
Monolith reduces complexity, speeds delivery for small teams [check]
Solution
Step 1: Compare memory usage and accuracy
Redis Sets store all unique IDs exactly, which is memory prohibitive at 100 million users; HyperLogLog uses fixed small memory with ~2% error.Step 2: Evaluate operational needs
HyperLogLog supports efficient merges and approximate counts, suitable for large scale; Redis Sets are exact but scale poorly in memory.Final Answer:
Option D -> Option DQuick Check:
HyperLogLog trades accuracy for fixed small memory at scale [check]
Solution
Step 1: Identify centralized ID generator role
It serializes ID generation requests to maintain uniqueness and ordering.Step 2: Analyze scaling impact
At 10x scale, the single generator becomes a serialization bottleneck that cannot be sharded or scaled horizontally, limiting throughput.Final Answer:
Option C -> Option CQuick Check:
Centralized generator serialization -> first bottleneck at scale [check]
