Practice
1. In a Cache Aside pattern, at step 3 the application checks the cache and finds a miss. What happens next at step 4?
easy
Solution
Step 1: Understand Cache Aside flow
On cache miss, application queries DB and updates cache explicitly.Step 2: Eliminate other options
Cache Aside does not auto-load cache (A); it does not return null or stale data (C, D).Final Answer:
Option A -> Option AQuick Check:
Application loads DB and updates cache on miss [check]
Hint: Cache Aside: app loads DB and updates cache on miss [check]
Common Mistakes:
2. A ticket booking system must prevent double booking by temporarily reserving seats during payment processing. Which component is best suited to handle this seat locking with a timeout?
easy
Solution
Step 1: Identify seat locking requirements
Seat locking must be temporary with automatic expiration to avoid indefinite holds if payment fails.Step 2: Evaluate options for temporary locks
Relational DB locks block resources and can cause deadlocks; message queues serialize but add latency and don't expire locks; client-side locking is unreliable and insecure. Distributed cache with TTL provides automatic expiration and fast access.Final Answer:
Option C -> Option CQuick Check:
Redis TTL auto-expires locks, preventing stale seat holds [check]
Hint: Temporary locks need auto-expiry; Redis TTL fits best [OK]
Common Mistakes:
3. In the Snowflake ID generation flow, at Step 3 the sequence number is incremented after the timestamp and machine ID are set. What happens if the sequence number exceeds its maximum value within the same millisecond?
easy
Solution
Step 1: Understand sequence number role in Snowflake
The sequence number differentiates IDs generated within the same millisecond on the same machine.Step 2: Analyze overflow handling
If the sequence exceeds its max (e.g., 4095), the generator must wait for the next millisecond to avoid duplicates. Resetting immediately (A) risks duplicates; wrapping (C) causes collisions; incrementing machine ID (D) is not part of the design.Final Answer:
Option A -> Option AQuick Check:
Sequence overflow -> wait next millisecond to avoid duplicates [check]
Hint: Sequence overflow blocks until next millisecond [OK]
Common Mistakes:
4. If Redis becomes unavailable in a centralized rate limiting system, what is the immediate failure mode for incoming requests?
medium
Solution
Step 1: Understand Redis unavailability impact
Without Redis, the centralized counter is unreachable, so rate limiting cannot be enforced.Step 2: Check fallback behavior
Most implementations allow requests to proceed without rate limiting to avoid blocking, risking overload.Final Answer:
Option A -> Option AQuick Check:
Redis down -> no rate limiting -> requests allowed unchecked [check]
Hint: No Redis means no rate limiting, requests pass unchecked [check]
Common Mistakes:
5. At 10x scale, which component in a primary-replica replication system is most likely to fail first and why?
hard
Solution
Step 1: Identify bottleneck at 10x scale
Replication log volume grows linearly with writes, stressing network bandwidth between primary and replicas.Step 2: Compare other components
Primary CPU scales with writes but often has headroom; replica storage I/O and query layer scale with reads, less impacted initially.Final Answer:
Option C -> Option CQuick Check:
Replication network bandwidth -> first bottleneck at scale [check]
Hint: Replication network saturates first at scale [check]
Common Mistakes:
