Practice
1. A real-time leaderboard system must handle millions of score updates per second with low latency and provide instant rank queries. Which component is best suited to store and update scores efficiently while maintaining sorted order?
easy
Solution
Step 1: Identify data structure for sorted order and fast updates
Redis Sorted Sets provide O(log N) insertion and rank queries with in-memory speed, ideal for real-time leaderboards.Step 2: Eliminate other options based on latency and ordering
Relational DBs have higher write latency and complex locking; Kafka stores events but doesn't maintain sorted order; MongoDB lacks efficient sorted queries at scale.Final Answer:
Option D -> Option DQuick Check:
Redis Sorted Sets maintain sorted scores with low latency [check]
Hint: Sorted Sets keep scores sorted with fast rank queries [check]
Common Mistakes:
2. In the AI Code Assistant request flow, at step 4 the Retriever component queries the vector index with the user's code context embedding. What happens if the vector index is temporarily unavailable at this step?
easy
Solution
Step 1: Understand Retriever fallback logic
Retriever cannot query vector index if unavailable; raw code files (A) are not indexed for fast retrieval; indefinite retries (C) would block latency budget; empty results (B) degrade quality but not typical fallback.Step 2: Recognize fallback to relational DB
System uses relational DB fallback (D) with keyword matching to maintain some retrieval capability under vector index failure.Final Answer:
Option A -> Option AQuick Check:
Fallback to keyword DB preserves retrieval under vector index failure [check]
Hint: Retriever falls back to keyword DB if vector index fails [check]
Common Mistakes:
3. In the request flow for generating a user's feed, at step 5 the Feed Aggregator receives multiple candidate posts from different microservices. What does the Feed Aggregator do at this step before sending the feed to the user?
easy
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]
Hint: Aggregate, dedupe, rank before sending feed [OK]
Common Mistakes:
4. For a globally distributed collaborative editor with many offline users, which approach better supports eventual consistency and offline edits, and why?
medium
Solution
Step 1: Compare OT and CRDT for offline and distributed scenarios
OT typically requires a central server to order and transform operations, making offline support complex.Step 2: Understand CRDT advantages
CRDTs are designed for decentralized environments, allowing local operations to be merged eventually without coordination, ideal for offline edits and global distribution.Final Answer:
Option C -> Option CQuick Check:
CRDTs enable offline edits and eventual consistency without central coordination [check]
Hint: CRDTs merge offline edits without central coordination [OK]
Common Mistakes:
5. You must design a system that processes high-volume event streams with strict ordering per customer but can tolerate some message duplication. Which approach is best?
medium
Solution
Step 1: Evaluate ordering and throughput needs
Single partition guarantees ordering but limits throughput severely.Step 2: Assess partitioning by customer ID
Partitioning by customer ID preserves ordering per customer and allows parallel consumption.Final Answer:
Option A -> Option AQuick Check:
Partition key + consumer group balances order and scale [check]
Hint: Partition by customer ID for order and parallelism [OK]
Common Mistakes:
