STANDARDwalkthrough

Road Network Graph and Partitioning

4 of 8
3 related
A routing server receives 10,000 route requests per second. Each request needs to traverse a graph of 500 million nodes and over 1 billion edges.
256 GB
of memory for the filter
10K
requests/sec peak throughput
000x
faster sequential I/O
A Contraction Hierarchies query touches 1,000 nodes, so that is 1,000×100 \mus=100 ms1{,}000 \times 100\text{ \mu s} = 100\text{ ms} per query on SSD. At 10K QPS, we need 1,000 seconds of compute per second, clearly impossible.
If we store this graph on SSD and perform random access during pathfinding, each node lookup costs about 100 microseconds.
The constraint: the entire graph must live in RAM. Each node stores latitude (8 bytes), longitude (8 bytes), elevation (4 bytes), and adjacency metadata (roughly 180 bytes for edge lists, road type, speed limit, turn restrictions).
That totals about 200 bytes per node. Total memory: 500M nodes×200 B=100 GB500\text{M nodes} \times 200\text{ B} = 100\text{ GB}.
With RAM, each node lookup costs 100 nanoseconds: 1,000×100 ns=100 \mus1{,}000 \times 100\text{ ns} = 100\text{ \mu s} per query. That is 1,000x faster than SSD.
We partition the global graph into geographic regions (e.g., US-West, US-East, Europe-West) so each server holds one region's subgraph. A cross-partition route (San Francisco to New York) is handled by identifying partition boundary nodes, the highway entry and exit points where regions meet.
The query engine routes within the source partition to the boundary, jumps to the destination partition, and stitches the paths together. OpenStreetMap provides the open-source road graph: 8 billion GPS points contributed by 2 million mappers, forming the same node-edge structure.
Google builds its graph from Street View imagery, satellite data, and partner feeds. Trade-off: 100 GB per server means we need high-memory machines (128 to 256 GB RAM), which limits the number of servers we can deploy.
Fewer, larger servers reduce operational complexity but create bigger blast radii if one crashes. The alternative, sharding by hash instead of geography, would scatter geographically adjacent nodes across machines, destroying data locality for pathfinding.
What if the interviewer asks: how do we handle graph updates when new roads are built? We rebuild the affected partition's subgraph and hot-swap it into the routing server.
The old graph serves queries until the new one is loaded, ensuring zero downtime.
Why it matters in interviews
Interviewers use this concept to test whether we can derive the 100 GB in-memory requirement from first principles and explain why geographic partitioning beats hash-based sharding for graph traversal workloads.
Related concepts