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 follower distribution impact on fan-out
Fan-out on write for users with millions of followers causes huge write amplification and storage overhead. Fan-out on read for low-follower users increases read latency unnecessarily.Step 2: Evaluate hybrid approach benefits
Hybrid approach balances write amplification and read latency by applying fan-out on write only where follower count is manageable, and fan-out on read for heavy hitters.Final Answer:
Option A -> Option AQuick Check:
Hybrid fan-out balances write cost and read latency [check]
Solution
Step 1: Understand heartbeat role in client-side discovery
Heartbeats keep registry updated; without them, registry cannot detect crashed instances.Step 2: Trace failure impact
Without heartbeats, registry retains stale instances; clients cache stale data and send requests to dead instances causing failures.Final Answer:
Option A -> Option AQuick Check:
Registry removes crashed instances only if heartbeats present [check]
Solution
Step 1: Identify scaling bottlenecks
Central metadata service (The central shard metadata service, due to increased coordination overhead) may be distributed or avoided; shards (The individual database shards, because storage capacity limits are reached first) scale horizontally; client caches (The client-side routing cache, as it cannot handle the increased number of shards efficiently) can be sharded or refreshed incrementally.Step 2: Analyze hash ring management at scale
Hash ring management (The hash ring management service, because updating and propagating ring changes becomes a bottleneck) requires updating and propagating ring changes to all nodes; at 10x scale, this coordination overhead and update frequency cause it to become the first bottleneck.Final Answer:
Option C -> Option CQuick Check:
Hash ring updates bottleneck first at large scale [check]
Solution
Step 1: Identify scaling bottlenecks
Physical nodes scale horizontally; network and hash function scale well with optimizations.Step 2: Analyze token metadata service
Managing many virtual nodes and frequent node changes increases metadata complexity and update frequency, causing bottlenecks.Final Answer:
Option B -> Option BQuick Check:
Token metadata service complexity grows fastest, causing first failure [check]
