Design the backend system for a ride-hailing service like Uber. The system must support millions of concurrent riders and drivers across the globe, handling real-time location updates, ride requests, driver-rider matching, dynamic pricing, trip tracking, and payments. When a rider opens the app they should see an ETA map with nearby drivers; when they request a ride the system must match them with the best available driver within seconds, then track the trip and handle payment settlement. Key components to design: (1) Rider & Driver services — registration, authentication, profile, ratings. (2) Demand service — ingest and persist rider ride requests. (3) Supply service — ingest driver location updates every 4 seconds and maintain an eventually-consistent geospatial index of available drivers. (4) Dispatch / Matching service — given a rider pickup location, find the K nearest available drivers, rank by ETA/distance/surge, and assign the best driver atomically; handle race conditions when multiple riders compete for the same driver. (5) Pricing service — compute base fare, time & distance components, and dynamic surge multipliers by dividing cities into H3 hexagonal cells, continuously computing demand-supply ratios per cell and pushing multipliers to clients. (6) Trip service — maintain a state machine for every trip (REQUESTED → MATCHED → DRIVER_EN_ROUTE → ARRIVED → IN_PROGRESS → COMPLETED) using an event-sourced log for fault-tolerance; expose APIs for clients to poll or stream state. (7) Notification service — push/SMS events to riders and drivers. (8) Payment service — calculate final fare, apply promotions, charge the rider, transfer earnings to the driver, and support split fares and tips. (9) Analytics pipeline — real-time dashboards for city ops, ML features for demand forecasting and fraud detection. The entire system must be horizontally scalable, regionally deployed, and tolerate server, AZ, and regional failures with <1 min detection and <5 min recovery while keeping P99 end-to-end latency under 2 s for matching and 300 ms for read APIs.