Practice
1. In the photo feed generation flow, at step 4 the Feed Worker fetches stories from the Stories Service cache. What happens if the cache TTL for a user's stories has expired at this step?
easy
Solution
Step 1: Trace Feed Worker behavior at cache miss
When TTL expires, the cache is stale. The Feed Worker must avoid blocking feed generation.Step 2: Understand asynchronous cache refresh
To maintain low latency, the Feed Worker returns empty stories immediately and triggers async cache refresh. Blocking fetch (B) would increase latency. Returning stale data (A) risks outdated content. Skipping stories silently (C) loses user experience.Final Answer:
Option A -> Option AQuick Check:
Async cache refresh avoids blocking feed generation [check]
Hint: Async cache refresh avoids blocking feed generation [OK]
Common Mistakes:
2. In a CQRS system, a write request updates the primary database at Step 3. At Step 5, the read replica receives an update event. What is the state of the read replica at Step 6 immediately after receiving the event but before applying it?
easy
Solution
Step 1: Trace event arrival at read replica
Upon receiving the update event, the read replica has not yet applied it, so data is stale.Step 2: Understand read replica behavior
Read replicas serve stale data until the event is processed; they do not reject or queue reads.Final Answer:
Option D -> Option DQuick Check:
Read replicas serve stale data until update applied [check]
Hint: Read replicas lag briefly, serve stale data until updated [check]
Common Mistakes:
3. For ranking posts in a Reddit-like system with millions of votes per minute, which architecture better balances real-time freshness and scalability?
medium
Solution
Step 1: Evaluate synchronous centralized DB approach
Use a single centralized database to compute ranking scores on every vote synchronously causes write bottlenecks and high latency, unsuitable for millions of votes per minute.Step 2: Compare streaming vs batch and client-side
Batch (Use batch jobs every hour to recompute rankings from raw vote data) has high latency, unsuitable for real-time freshness. Client-side (Use client-side ranking computation to reduce server load) can't guarantee consistent global ranking. Streaming pipeline (Use a streaming pipeline (Kafka + Flink) to incrementally update scores asynchronously) provides near real-time incremental updates and scales horizontally.Final Answer:
Option A -> Option AQuick Check:
Streaming pipelines enable scalable, near real-time ranking updates [check]
Hint: Streaming pipelines scale and update rankings near real-time [check]
Common Mistakes:
4. For timeline generation at scale, which architecture better handles users with millions of followers and why?
medium
Solution
Step 1: Analyze push vs pull trade-offs
Push fan-out is efficient for low-follower users but expensive for celebrities; pull is costly on read latency.Step 2: Evaluate hybrid approach
Hybrid uses push for most users, pull for celebrities, balancing latency and write amplification.Step 3: Eliminate other options
Pure push (A) causes huge write amplification; pure pull (C) causes high read latency; global sorted set (D) is hard to scale and update asynchronously.Final Answer:
Option C -> Option CQuick Check:
Hybrid push-pull balances write cost and read latency [check]
Hint: Hybrid push-pull fits follower count extremes [check]
Common Mistakes:
5. If the API Gateway component is removed from a microservices architecture that relies on it for authentication and rate limiting, what is the most likely failure mode?
medium
Solution
Step 1: Understand API Gateway role
API Gateway centralizes authentication and rate limiting; without it, these controls are lost.Step 2: Trace failure consequences
Load Balancer does not perform authentication but may attempt to handle some traffic control, increasing latency; backend services may be exposed to unauthorized requests.Final Answer:
Option D -> Option DQuick Check:
Removing API Gateway removes centralized auth, Load Balancer can't fully compensate [check]
Hint: No API Gateway -> Load Balancer tries but can't secure backend [check]
Common Mistakes:
