Practice
Solution
Step 1: Identify spatial indexing needs
Relational DBs with lat/lon indexes (Use a relational database with latitude and longitude columns and perform range queries with indexes) do not scale well for large radius queries and millions of points due to expensive range scans.Step 2: Evaluate Geohash suitability
Geohash (Use a Geohash-based spatial index to bucket locations into hierarchical grids) encodes locations into hierarchical grids enabling efficient prefix queries for nearby searches, making it ideal for large-scale spatial indexing.Final Answer:
Option B -> Option BQuick Check:
Geohash buckets locations into grids for fast proximity queries [check]
Solution
Step 1: Analyze delivery semantics
Exactly-once requires atomicity across producer and consumer; at-least-once (A) can cause duplicates; at-most-once (C) risks loss; fire-and-forget (D) ignores reliability.Step 2: Evaluate architecture complexity
Two-phase commit (B) ensures atomic commit across components, enabling exactly-once semantics despite complexity; idempotent consumers (A) reduce duplicates but don't guarantee exactly-once.Final Answer:
Option B -> Option BQuick Check:
Two-phase commit -> atomic exactly-once delivery despite complexity [check]
Solution
Step 1: Evaluate update and query trade-offs
Rebuilding entire HNSW on every update (Use a single monolithic HNSW index rebuilt entirely on every update) is too slow for real-time.Step 2: Consider hybrid index approach
Maintaining an immutable bulk index plus a small dynamic index (Maintain an immutable HNSW index for bulk data plus a small dynamic index for recent inserts) allows fast queries and incremental updates.Final Answer:
Option B -> Option BQuick Check:
Hybrid immutable + dynamic HNSW balances update speed and query latency [check]
Solution
Step 1: Analyze write frequency and freshness needs
High-read, low-write favors lazy loading and invalidation to avoid cache update overhead.Step 2: Evaluate caching strategies
Write-through adds write latency; write-back risks stale data; cache-aside balances freshness and performance.Final Answer:
Option D -> Option DQuick Check:
Cache-aside suits high-read, low-write with freshness [check]
Solution
Step 1: Identify coordinator role and scaling limits
The warming coordinator manages global warming state and task assignment, which is hard to shard.Step 2: Compare other components
Database can be scaled with replicas; cache servers scale horizontally; network scales with capacity upgrades.Step 3: Conclude bottleneck
Coordinator's centralized state causes it to fail first at 10x scale.Final Answer:
Option D -> Option DQuick Check:
Centralized coordinator state limits sharding, causing bottleneck [check]
