Design a System for Real-Time Fleet Management

System Design
Hard
Uber
147.9K views

Design a system to track and optimize the routes of thousands of vehicles (delivery vans, buses) in real-time. Focus on pathfinding algorithms and high-speed data ingestion.

Why Interviewers Ask This

Interviewers at Uber ask this to evaluate your ability to architect scalable, low-latency systems under extreme concurrency. They specifically test your grasp of real-time data ingestion pipelines, dynamic pathfinding algorithms for millions of nodes, and trade-offs between consistency and availability in a distributed environment.

How to Answer This Question

1. Clarify requirements immediately: define scale (e.g., 50k vehicles), latency goals (sub-second updates), and core functions like routing vs. tracking. 2. Estimate capacity using rough math for messages per second and storage needs to justify component choices. 3. Outline the high-level architecture: propose Kafka or Pulsar for ingestion, Redis for geospatial caching, and a microservices layer for logic. 4. Deep dive into the critical algorithm: discuss A* or Dijkstra optimizations with pre-computed road graphs and how you handle traffic re-routing dynamically. 5. Address failure scenarios like node crashes or network partitions, explaining your replication strategy and fallback mechanisms for route calculation.

Key Points to Cover

  • Explicitly defining latency constraints and throughput metrics before designing components
  • Proposing a decoupled architecture using message queues like Kafka for high-speed ingestion
  • Demonstrating knowledge of advanced graph algorithms optimized for dynamic traffic conditions
  • Addressing geospatial data challenges through efficient indexing strategies like GeoHash
  • Discussing specific failure modes and how the system maintains availability during partial outages

Sample Answer

To design a real-time fleet management system for thousands of vehicles, I would first clarify that we need sub-500ms latency for route updates and support for 100,000 concurrent connections. I'd start with a high-level view: vehicles send GPS pings via gRPC to an API Gateway, which buffers incoming streams into Apache Kafka to decouple ingestion from processing. For state management, I'd use Redis with GeoHash indexing to track vehicle locations efficiently, allowing O(1) lookups for nearby dispatches. The core challenge is the pathfinding engine. Instead of running standard Dijkstra on every request, I'd implement a hybrid approach using Contraction Hierarchies for static graph preprocessing, combined with real-time traffic weights fetched from a separate analytics service. When traffic changes, the system triggers incremental updates rather than recalculating entire paths. To ensure scalability, the routing service would be sharded by geographic region. If a region's load spikes, we auto-scale horizontally. Finally, for reliability, I'd ensure the system handles message duplication idempotently and uses eventual consistency for non-critical logs while maintaining strong consistency for active trip assignments to prevent double-bookings.

Common Mistakes to Avoid

  • Focusing solely on database schema without addressing the real-time streaming nature of GPS data
  • Suggesting synchronous blocking calls for pathfinding which would cause unacceptable latency spikes
  • Ignoring the cost of storing historical trajectory data versus keeping only current state
  • Overlooking the complexity of handling disconnected vehicles or intermittent network connectivity

Practice This Question with AI

Answer this question orally or via text and get instant AI-powered feedback on your response quality, structure, and delivery.

Start Practicing

Related Interview Questions

Browse all 150 System Design questionsBrowse all 57 Uber questions