Hello! Welcome to your next lesson on designing core infrastructure systems.
In our last lesson, we designed a scalable web crawler, focusing on the challenges of large-scale data ingestion, politeness, and fault tolerance. We saw how a pipelined architecture with distinct services for fetching and parsing could create a robust system.
Today, we're tackling your final requested deep dive: Design a navigation and ETA system (Uber focus), incorporating real-time traffic updates.
This problem shifts our focus from the batch-oriented world of data ingestion to the dynamic, low-latency domain of real-time geospatial services. While a web crawler interacts with relatively static web pages, a navigation system must react in milliseconds to a constantly changing world. For a Staff-level interview at a company like Uber or Google, a successful design requires a deep understanding of graph algorithms, distributed data processing, and the clever integration of machine learning to achieve high accuracy.
1. Framing the Problem: The Journey from A to B
At its heart, a navigation system answers two simple questions: "What's the best way to get from A to B?" and "How long will it take?" The complexity, of course, lies in the details. Let's first establish the functional and non-functional requirements.
Google Maps System Design Interview Question
To start, let's watch a brief overview of the requirements for a system like Google Maps, which forms the foundation of any navigation service.
Watch the first three minutes of this video (from 00:10 to 03:16). Pay attention to how the problem is broken down into core features (route finding, ETA) and essential qualities (availability, accuracy).
Synthesizing this and applying an Uber-specific context, our requirements are:
Functional Requirements:
- Given a start and end location, calculate the optimal route (e.g., fastest or shortest).
- Provide an accurate Estimated Time of Arrival (ETA) for that route.
- Incorporate real-time traffic data to adjust routes and ETAs dynamically.
- Provide data for turn-by-turn navigation instructions (though we won't design the UI for this).
Non-Functional Requirements:
- High Accuracy: The ETA must be very close to the actual travel time. This is critical for customer trust and for downstream systems like pricing.
- Low Latency: Route and ETA calculations must be returned to the user within a few hundred milliseconds.
- High Availability: The service must be extremely reliable. A failure means users can't get rides.
- Scalability: The system must handle millions of concurrent requests from users globally.
2. The Core Abstraction: A World of Graphs and Segments
The most natural way to model a road network is as a directed graph:
- Nodes (Vertices): Intersections.
- Edges: Road segments connecting two intersections. Edges are directed to handle one-way streets and differing traffic conditions in each direction.
- Edge Weights: The "cost" to traverse an edge. This could be distance, but for ETA, the most important weight is travel time.
A naive approach might be to run a shortest path algorithm like Dijkstra on the entire global road network graph for every request. Given your experience, you can likely see why this is not feasible. The world's road network contains tens of millions of nodes and hundreds of millions of edges. Running Dijkstra on a graph of this magnitude for millions of concurrent users would be computationally impossible.
The key to solving this is hierarchy and pre-computation. We don't need to explore every tiny residential street in a distant city to find a cross-country route.
Google Maps System Design Interview Question
The video 'Google Maps System Design Interview Question' provides an excellent explanation of how to make routing scalable by partitioning the graph.
Please watch the segment from 05:38 to 24:22. This is a critical section that covers three core ideas: Segments (05:38 - 08:52): The concept of dividing the map into small, manageable grid squares (e.g., 1km x 1km). Intra-Segment Routing (08:52 - 15:06): How shortest paths between all major junctions within a single segment can be pre-calculated and cached. Inter-Segment Routing (15:06 - 24:22): The main scalability trick. How to find long-distance routes by running Dijkstra on a much smaller, higher-level graph composed only of the entry/exit points of these segments. The video also introduces 'Mega-Segments' for even larger scales.
This hierarchical approach is the foundation of any scalable routing engine. By pre-calculating paths within segments and creating an abstract graph of segment connections, we dramatically reduce the search space for any given request.
3. Deep Dive: Incorporating Real-Time Traffic
The edge weights (travel times) in our graph are not static. A road segment that takes 2 minutes to cross at 3 AM might take 20 minutes at 5 PM. Our system's accuracy depends entirely on using fresh, relevant edge weights. This is where we "incorporate real-time traffic updates."
1. Data Source: The Fleet on the Ground
For a company like Uber, the primary source of real-time traffic data is its own network of drivers. Every active driver's device is periodically sending location pings (latitude, longitude, timestamp, heading) to the backend.
2. The Data Processing Pipeline
We need a system to turn this firehose of raw GPS pings into meaningful average speeds for every road segment in our graph.

The pipeline looks like this:
- Ingestion: Driver apps send GPS pings via a persistent connection (e.g., WebSocket) to a Location Service.
- Streaming: The Location Service publishes these events to a message queue like Kafka. This decouples ingestion from processing and provides a durable buffer.
- Processing: A stream processing engine (like Apache Flink or Spark Streaming) consumes the events from Kafka. For each ping, it performs several key steps:
- Map Matching: A raw GPS coordinate is often noisy and not precisely on a road. A Map Matching algorithm (often using a Hidden Markov Model, as described in the High Scalability article LINK) is used to snap the coordinate to the most probable road segment on the map.
- Speed Calculation: By comparing consecutive pings from the same driver, the processor can calculate the travel speed on a specific road segment.
- Aggregation: The processor aggregates speeds from many different drivers over a short time window (e.g., the last 5 minutes) for each road segment to calculate a robust, real-time average speed.
- Updating the Graph: The newly calculated average speeds are then used to update the travel time weights in the main graph database that the routing engine uses.
This continuous flow ensures that when the Graph Processing Service plans a route, it uses edge weights that reflect traffic conditions from just a few minutes ago.
4. The Staff+ Differentiator: A Hybrid Physical-ML Model
A purely algorithmic approach, even with real-time traffic, has its limits. It may not capture the nuances of weather, local events (e.g., a concert letting out), or the subtle differences between a delivery trip and a passenger drop-off. This is where machine learning comes in. A Staff-level answer at Uber or Google would demonstrate an understanding of this hybrid approach.
DeepETA: How Uber Predicts Arrival Times Using Deep Learning
Uber's engineering blog provides a fascinating look at DeepETA, their production system for predicting arrival times. It highlights the shift from purely algorithmic methods to a hybrid model. This is the kind of advanced, real-world context that interviewers at this level are looking for.
Please read the introduction and the 'Problem Statement' section. The key concept here is 'ETA post-processing'. Understand that Uber doesn't replace the routing engine with ML. Instead, they use the routing engine to get a baseline ETA, and then an ML model predicts the residual (the difference between the baseline and the real-world outcome).
This hybrid model is powerful:
- The Routing Engine does what it does best: solve a complex combinatorial problem (finding the best path through a graph).
- The ML Model does what it does best: learn complex, non-linear patterns from vast amounts of historical data (e.g., how much does rain in Seattle at 4 PM on a Tuesday typically add to the ETA for a given route?).
The ML model takes features like the route itself, time of day, day of week, origin/destination region, and weather forecasts to predict the small correction that makes the final ETA much more accurate.
5. Deep Dive: High-Throughput Geospatial Indexing
A crucial sub-problem that enables this whole system is managing driver locations. The service that collects pings for our traffic pipeline must also serve other real-time needs, like showing nearby cars to riders. This requires a specialized database that can handle an immense write load (millions of drivers updating their location every few seconds) and perform efficient spatial queries (e.g., "find all available drivers within a 2-mile radius of the rider").
Your standard relational database with a B-Tree index on latitude and longitude columns is not suited for this 2D proximity search. This is a classic system design deep dive.
Design Uber w/ a Ex-Meta Staff Engineer: System Design Interview breakdown
Let's watch a detailed breakdown of the trade-offs involved in building this location database. This is a perfect example of the Staff-level depth you're aiming for.
Watch the segment from 34:32 to 47:55. The speaker does an excellent job comparing and contrasting different solutions: Naive SQL: Why it fails due to indexing and transaction limits. SQL with Geospatial Indexes (Quadtrees): An improvement, but still has issues with high-frequency updates and re-indexing costs. In-Memory Store (Redis) with Geohashing: The optimal solution for this use case, handling high throughput writes and providing fast proximity searches. He also touches on Uber's custom H3 library.
The key takeaway is that for a high-throughput, write-heavy, real-time spatial indexing problem, an in-memory solution like Redis with Geohashing (or a custom variant like Uber's H3) is superior to traditional disk-based databases, even those with spatial indexes.
Conclusion
We've designed a comprehensive system for navigation and ETA calculation that meets the demands of a service like Uber. It's built on a foundation of classic algorithms but scaled and refined with modern distributed systems patterns and machine learning.
Key Takeaways:
- Scalable Routing: The massive global road network graph is made manageable using a hierarchical partitioning scheme (segments and mega-segments) and pre-computation.
- Real-Time Traffic: Live traffic is incorporated by a real-time data pipeline (Kafka + Flink/Spark) that processes location pings from the driver fleet, performs map matching, and continuously updates the travel time weights on the graph edges.
- State-of-the-Art Accuracy: A purely algorithmic approach is enhanced by a hybrid ML model (like DeepETA) that predicts the residual error between the physical model's ETA and the ground truth, accounting for factors the graph can't capture.
- Geospatial Indexing: The underlying location data is managed by a high-throughput system using geohashing (e.g., in Redis) to support both the traffic data pipeline and other real-time features.
Preview of the Next Lesson:
This lesson provided a deep dive into a critical component of a ride-sharing service. In our next module, "Designing Product & Platform Systems," we will zoom out and design the complete ride-sharing system, integrating the navigation service we just designed with other key components like driver-rider matching, pricing, and payments.