HARDDistributed Systems
Design Uber Ride-Sharing Platform
Design a ride-sharing application matching drivers with passengers, handling real-time location tracking, fare calculation, and payments.
Estimated Time: 45 minutes
Solution Overview
Uber system: Geospatial indexing (QuadTree/S2) for driver matching, WebSocket for real-time location, distributed trip state machine, payment gateway integration, surge pricing algorithm, trip matching service.
Matching
Use QuadTree to find nearby drivers within radius. Score by distance, rating, acceptance rate.
Trip Flow
- •Rider requests → Find drivers → Send requests → Driver accepts → Navigate → Complete → Payment
Surge Pricing
Monitor supply/demand ratio per region. Dynamic multiplier based on thresholds. Update every 5 mins.
Eta Calculation
Use historical traffic data + current conditions. Dijkstra or A* on road network graph.
Location Tracking
Drivers send GPS updates every 4s via WebSocket. Store in Redis geospatial index. Expire after 30s.