Lesson 1 of 14
Next❯

MSD-101 · Global taxi booking design

Global taxi booking: the big picture

⏱ 12 min 🎮 Hands-on ☁ Azure

1of 14

Your note

My notes for this lesson

Select any text in the lesson to highlight it or add a note. Saved in this browser.

    No highlights yet. Select a sentence in the lesson, then pick a colour or add a note.

    Reading settings

    For every lesson, saved in this browser.

    Text size
    Line spacing
    Font

    With IaaS you rent the virtual machine. Microsoft looks after the building, power and hardware; you patch the operating system.

    ⚡ 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 ↗

    Load
    Design switches
    Avg match time–
    Trips completed0
    Duplicate trips0
    Stale offers0
    Failed bookings0
    Queue0cap 3/s
    At 1M drivers250,000events / s
    Driver batteryMedium900 wake-ups / h

      🎯 Missions 0 / 6

      1. Turn idempotency OFF with a flaky network and cause 2 duplicate trips. Then turn it back ON.
      2. Kill 30% of driver apps with expiry OFF and watch stale offers pile up. Then turn expiry ON.
      3. Set GPS to 15 s or more and watch the ring lag behind the car.
      4. Turn drive-time matching OFF and catch a car sent the long way over the river.
      5. Trigger a region outage with failover OFF (bookings fail), then with failover ON.
      6. Start a surge with autoscale OFF, then ON, and compare the match time.
      1. 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.
      2. The design ideaStreams can lose a point. Commands can never happen twice.
      3. 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.

      RequirementTargetWhy this number
      Match timep95 under 10 sAfter 10 s riders open another app
      Location freshness≤ 5 s oldOlder and the car jumps on the map
      Availability99.95% for bookingAbout 22 minutes down a month
      Scale1M drivers, 3M trips a day≈ 250,000 GPS events a second
      OfflineBooking survives 30 sLifts and car parks are normal
      BatteryGPS 4 s on trip, 15–30 s idleAccuracy only where it matters

      🎮 Playground🎛 Size the load🤔 Choose a design

      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.

      Ready for more?The full lesson adds the technical explanation, interview questions and quick revision.

      Test yourself

      5 questions. Get 4 right and this lesson is marked complete.

      1. 1. Priya taps Book, the network drops, and the app retries. What stops a second trip?
      2. 2. 1M drivers send GPS every 4 s. About how many events a second is that?
      3. 3. Which message is a command, not a stream?
      4. 4. Why not send every location update as a push notification?
      5. 5. What is the first step of any system design?

      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