MSD-101 · Global taxi booking design
Global taxi booking: the big picture
⏱ 12 min 🎮 Hands-on ☁ Azure ✓ Completed
⚡ The 30-second answer
A taxi booking app has two jobs: keep a live map of moving drivers, and turn one tap into exactly one trip. Live data is a stream that may lose a point; a booking is a command that must never happen twice. The proven design gives them different roads: a WebSocket stream for location, HTTPS with an idempotency key for commands, and push only to wake the app.
- Write requirements with real numbers
- Size the location load
- Split streams from commands
- Pick the hybrid design and say why
Try it
Play with the design before you read about it. Everything runs on this page.
A small city running this design. Flip a switch, kill driver apps, trigger an outage, and watch the numbers. Open full screen ↗
🎯 Missions 0 / 6
- Turn idempotency OFF with a flaky network and cause 2 duplicate trips. Then turn it back ON.
- Kill 30% of driver apps with expiry OFF and watch stale offers pile up. Then turn expiry ON.
- Set GPS to 15 s or more and watch the ring lag behind the car.
- Turn drive-time matching OFF and catch a car sent the long way over the river.
- Trigger a region outage with failover OFF (bookings fail), then with failover ON.
- Start a surge with autoscale OFF, then ON, and compare the match time.
Drag the sliders. One small number on the phone (the GPS interval) changes the whole backend.
🤔 Drivers move every second and riders want to see them live. How should the phones and the backend talk?
Compare all three side by side
| Approach | Pros | Cons | When to choose |
|---|---|---|---|
| Polling (REST every few seconds) | Simplest to build. Works with any backend and any proxy. | Millions of empty requests, battery drain, and updates are always up to one interval late. | A first version in one city with a few hundred drivers. |
| Push notifications only | Reaches the phone even when the app is in the background. | No ordering, no delivery guarantee, throttled by the OS. Fine for “driver arrived”, useless for a 4-second stream. | Only to wake the app or announce rare events. |
| Hybrid: WebSocket for live, HTTPS for commands, push to wake | Under 1 s updates, one connection per phone, safe retries for anything that costs money. | More moving parts. The app must reconnect and re-sync state after every drop. | Any real-time app at city or global scale. |
✅ Choose the hybrid design. Live data (GPS, “driver is 2 minutes away”) is a stream: lose one point and the next one replaces it. Commands (book, cancel, pay) are the opposite: each must happen exactly once. Mixing them in one channel is the most common design mistake in ride apps.
- The problemPriya lands at the airport at 11 pm and opens CityHop. She taps Book and walks into the lift. The signal drops for 20 seconds. When the doors open, two drivers are coming for her and her card shows two holds.
- The design ideaStreams can lose a point. Commands can never happen twice.
- In real lifeRide apps in Southeast Asia handle New Year’s Eve peaks of several times normal demand. Teams that split streams from commands can scale the location pipeline on its own, without touching the booking API that moves money.
Start with a question
Priya lands at the airport at 11 pm and opens CityHop. She taps Book and walks into the lift. The signal drops for 20 seconds. When the doors open, two drivers are coming for her and her card shows two holds.
Nothing was “broken”. The app retried a booking that had already worked. This lesson is about seeing that problem before you write any code.
Explain it like I'm 10
Think of a school bus app. The bus sends “I am here” every few seconds. If one message gets lost, the next one is fine. But when you press “Save me a seat”, that must happen once, even if you press it three times. Two kinds of messages, two kinds of rules.
The technical explanation
Start every design with requirements. Functional: see cars, book, get matched, track the trip, pay. Non-functional, with numbers: match in under 10 s (p95), car on the map no older than 5 s, booking 99.95% available, survive a 30 s signal loss.
Then estimate. With 1M drivers online sending GPS every 4 s, the backend takes about 250,000 location events a second. Change the interval to 2 s and it doubles. One small mobile setting changes the whole backend bill.
Now split the traffic. Location is a high-volume stream: losing one point is fine, the next replaces it. Booking, cancel and pay are low-volume commands: each must happen exactly once and be safe to retry.
That gives the hybrid design: one WebSocket per open app for live data, HTTPS with an idempotency key for commands, and push notifications only to wake a backgrounded app. The server is always the source of truth.
| Requirement | Target | Why this number |
|---|---|---|
| Match time | p95 under 10 s | After 10 s riders open another app |
| Location freshness | ≤ 5 s old | Older and the car jumps on the map |
| Availability | 99.95% for booking | About 22 minutes down a month |
| Scale | 1M drivers, 3M trips a day | ≈ 250,000 GPS events a second |
| Offline | Booking survives 30 s | Lifts and car parks are normal |
| Battery | GPS 4 s on trip, 15–30 s idle | Accuracy only where it matters |
Real-world scenario
Ride apps in Southeast Asia handle New Year’s Eve peaks of several times normal demand. Teams that split streams from commands can scale the location pipeline on its own, without touching the booking API that moves money.
Test yourself
5 questions. Get 4 right and this lesson is marked complete.
Pass the quiz to complete this lesson.
Next: Rider app and driver app →Questions people ask
How do I start a taxi app system design in an interview?
Spend the first 5 minutes on requirements and numbers: functional features, then latency, scale, availability and offline targets. Then estimate load (events a second), split streams from commands, and only then draw boxes.
WebSocket or polling for live driver location?
WebSocket for the live stream while the app is open, plain HTTPS for commands like book and pay, and push notifications only to wake a backgrounded app. Polling is fine only for a small first version.
How do I stop a user from being charged twice?
Send an idempotency key with every booking and payment, reuse it on every retry, and have the server return the first result when it sees the key again.
Interview questions
How this topic comes up in system design interviews. Answer out loud first, then open the model answer.
beginner What are the two main jobs of a taxi booking backend?
Keep a fresh live map of drivers (a high-volume stream) and turn a booking tap into exactly one trip (a low-volume command that must be idempotent).
intermediate Estimate the location load for 1M drivers at a 4 s interval and say what it means for the design.
About 250,000 events a second, roughly 50 MB/s. A normal REST API is the wrong entry point; you need a streaming ingest (WebSocket gateway into Event Hubs) and an in-memory store for the latest position.
advanced Design the mobile app and backend for a global ride-hailing app.
Split stream and commands. Stream: driver WebSocket → Web PubSub → Event Hubs → location service → Redis geo index with a 30 s expiry. Commands: HTTPS through Front Door and API Management with idempotency keys, trips in Cosmos DB by city. Matching re-ranks nearby drivers by Azure Maps ETA. Mobile: outbox with backoff, re-sync on reconnect, push only to wake, battery-aware GPS, one region per market.
Quick revision
Remember
- Write requirements with real numbers
- Size the location load
- Split streams from commands
- Pick the hybrid design and say why
- Ask “can this message be lost?” for every arrow you draw. If yes, it is a stream. If no, it is a command and needs an idempotency key, retries with backoff and a server-side check.
One line to remember
“Streams can lose a point. Commands can never happen twice.”
Official documentation
- Azure Web PubSub overview (Microsoft Learn)
- Azure Event Hubs (Microsoft Learn)
- Azure Well-Architected Framework: reliability (Microsoft Learn)