Design a Ride-Hailing Service (Uber/Lyft)

System Design
Hard
Uber
109.5K views

Design the core matching and real-time location tracking components. Focus on geospatial indexing (Geohash), estimating ETA, and high-volume matching.

Why Interviewers Ask This

Interviewers ask this to evaluate your ability to handle massive scale geospatial data challenges. They specifically test your knowledge of spatial indexing algorithms like Geohash, your understanding of real-time latency constraints in high-frequency matching systems, and your capacity to balance consistency with availability when estimating ETAs for millions of concurrent users.

How to Answer This Question

1. Clarify requirements immediately: Define scope (e.g., number of drivers/users), latency goals (sub-second matching), and consistency needs. 2. Propose a high-level architecture: Outline components for the Driver App, Rider App, Matching Service, and Location Stream Processor. 3. Deep dive into Geospatial Indexing: Explain how you will use Geohash or S2 geometry to partition the world grid, allowing efficient neighbor lookups without scanning the entire database. 4. Design the Matching Algorithm: Describe a two-step process—first filtering candidates within a radius using the index, then ranking them based on ETA, driver rating, and surge pricing logic. 5. Address Real-Time Tracking: Detail how to ingest location updates via WebSockets, store them in a time-series database, and calculate ETAs using historical traffic data combined with live map APIs. 6. Discuss Scaling: Mention sharding strategies by geographic region and handling spikes during rush hour.

Key Points to Cover

  • Explicitly mentioning Geohash or S2 geometry for efficient spatial queries
  • Describing a two-phase filtering and ranking algorithm for matching
  • Proposing a streaming architecture (Kafka/Pulsar) for real-time location ingestion
  • Addressing data partitioning strategies to handle regional traffic spikes
  • Balancing read/write consistency with low-latency requirements

Sample Answer

To design the core matching system for a service like Uber, I would start by defining our non-functional requirements: sub-200ms matching latency and 99.9% availability. First, we need a robust geospatial indexing strate…

Common Mistakes to Avoid

  • Ignoring the 'real-time' aspect and proposing batch processing for location updates
  • Failing to explain how to handle edge cases like drivers moving between grid cells
  • Overlooking the computational cost of calculating precise ETAs for thousands of candidates simultaneously
  • Not discussing how to scale the solution horizontally across different geographic regions

Sound confident on this question in 5 minutes

Answer once and get a 30-second AI critique of your structure, content, and delivery. First attempt is free — no signup needed.

Try it free

Related Interview Questions

Browse all 190 System Design questionsBrowse all 57 Uber questions