Practice
Solution
Step 1: Identify cache update timing
Write-Through updates cache and database synchronously, ensuring cache is always fresh.Step 2: Eliminate other patterns
Cache Aside updates cache only on misses, risking stale cache after writes; Read-Through only loads on reads; Write-Behind delays DB update, risking stale cache.Final Answer:
Option B -> Option BQuick Check:
Write-Through synchronously updates cache and DB [check]
Solution
Step 1: Identify storage needs for diffs
Storing diffs efficiently requires deduplication and immutability; content-addressable storage (CAS) stores objects by their hash, enabling reuse of identical content and saving space.Step 2: Evaluate other options
Relational DB with BLOBs stores full versions, wasting space; Redis is volatile and not durable for persistent storage; file system copies waste space and slow for merges.Final Answer:
Option C -> Option CQuick Check:
CAS stores objects by hash -> deduplication and fast retrieval [check]
Solution
Step 1: Identify location query requirements
Real-time matching requires low-latency spatial queries on dynamic driver locations.Step 2: Evaluate component suitability
Relational DBs (A) have high latency for frequent updates; Kafka (C) streams data but doesn't index locations; Hadoop (D) is batch-oriented and too slow. In-memory spatial indexes (B) provide fast nearest-neighbor queries and frequent updates.Final Answer:
Option A -> Option AQuick Check:
In-memory spatial index enables fast real-time location queries [check]
Solution
Step 1: Identify the role of inverted index engine
Distributed inverted index engines like Elasticsearch are optimized for multi-dimensional filtering and fast lookups on large datasets, supporting sub-second query latency.Step 2: Eliminate other options based on constraints
Relational DBs with composite indexes do not scale well for high-cardinality multi-facet queries; Redis is fast but storing precomputed results for all filter combinations is infeasible; message queues are for async processing, not low-latency queries.Final Answer:
Option C -> Option CQuick Check:
Distributed inverted index -> fast multi-facet filtering [check]
Solution
Step 1: Understand Rate Limiter behavior at Step 4
Rate limiter checks quota; if exceeded, it must prevent further load by rejecting requests immediately.Step 2: Eliminate incorrect behaviors
Queuing (A) delays overload but doesn't prevent it; forwarding with delay (C) risks backend overload; bypassing (D) violates rate limiting rules.Final Answer:
Option A -> Option AQuick Check:
Quota exceeded -> immediate 429 rejection [check]
