Lesson 4 of 14
❮Prev Next❯

MSD-101 · Global taxi booking design

The full architecture on Azure

⏱ 15 min 🎮 Hands-on ☁ Azure

4of 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

    The full design has a live path (driver WebSocket → Web PubSub → Event Hubs → location service → Redis geo index) and a command path (rider HTTPS → Front Door → API Management → trip service → Cosmos DB → matching). Six patterns hold it together: stream vs command, idempotency keys, an outbox, a geo index with expiry, pub/sub fan-out, and push to wake.

    • Follow all 16 steps
    • Map each box to Azure
    • Six patterns behind it
    • Build it yourself

    Try it

    Play with the design before you read about it. Everything runs on this page.

    No Azure subscription needed. Read the requirement, see the architecture, build it in a mock portal, send a booking through it, then break it.

    ☁ Simulate on Azure: Global taxi booking

    Priya lands at 11 pm and taps Book. In the next 10 seconds the system must find a free driver near her, across a river and in a country with its own region, and it must never book her twice, even when her signal drops in the lift.

    It must

    • Rider books a ride; the system offers it to the best nearby driver
    • Driver phones stream GPS; riders see the car live
    • Every booking happens exactly once, even when the app retries
    • Each country is served from a nearby Azure region, with a backup region

    With these numbers

    Match time
    p95 < 10 s
    Booking API
    p95 < 300 ms
    Availability
    99.95%
    Location load
    250k events/s
    Security
    No secrets in code

    🎓 Education-only simulation. Nothing is created in Azure and no subscription is needed.

    1. The problemA new architect joins the team and asks: “Where does a GPS point go, and where does a booking go?” Nobody can draw it on one page.
    2. The design ideaTwo paths: a fast lossy stream and a slow exact command road.
    3. In real lifeMany teams start with one service and one database. The first parts they split out are always location and matching, because those carry the heavy, spiky load.

    Start with a question

    A new architect joins the team and asks: “Where does a GPS point go, and where does a booking go?” Nobody can draw it on one page.

    If you cannot draw the two paths, you cannot debug them at 2 am.

    Explain it like I'm 10

    There are two roads in the city. One is a busy highway where thousands of tiny cars (GPS points) rush every second. The other is a quiet road with a guard (the API) who checks every important letter (a booking) and writes it in a book.

    The technical explanation

    Live path. The driver app keeps one WebSocket to Azure Web PubSub and sends a location event every 4 s. A Web PubSub event listener forwards these into Azure Event Hubs, so no web server takes 250k calls a second. The location service reads the stream and writes the latest point to Azure Managed Redis with a 30 s expiry.

    Command path. The rider’s Book call goes through Azure Front Door (nearest healthy region) and Azure API Management (token check, rate limit) to the trip service on Azure Container Apps, which saves the trip in Azure Cosmos DB after checking the idempotency key.

    Matching asks Redis for free drivers within 3 km, re-ranks them by drive time with Azure Maps, and offers the trip to one driver for 15 s over their WebSocket, or through Azure Notification Hubs if the app is in the background.

    Sign-in uses Microsoft Entra External ID; payment goes to an external provider that stores the card, so you keep only a token.

    BoxAzure serviceJob
    Global entryAzure Front DoorRoute to nearest healthy region
    API gatewayAzure API ManagementAuth, rate limits, versions
    Live connectionsAzure Web PubSubOne WebSocket per open app
    Location streamAzure Event Hubs≈ 250k events a second
    Live driver indexAzure Managed RedisGeo search, 30 s expiry
    Trips databaseAzure Cosmos DBDurable, multi-region
    Routes and ETAAzure MapsDrive-time ranking
    Push wake-upAzure Notification HubsReach backgrounded apps

    ☁ Simulate on Azure🎬 Watch the flow🧩 Patterns🧱 Build it

    Real-world scenario

    Many teams start with one service and one database. The first parts they split out are always location and matching, because those carry the heavy, spiky load.

    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. Which Azure path fits 250,000 driver location updates a second?
    2. 2. Why do driver positions in Redis expire after 30 s?
    3. 3. Why re-rank nearby drivers with Azure Maps?
    4. 4. Which service should a new design use for managed Redis on Azure?
    5. 5. Where is the trip saved with status REQUESTED?

    Pass the quiz to complete this lesson.

    Next: What breaks, and how the design survives →

    Questions people ask

    How do ride-hailing apps find the nearest driver so fast?

    Drivers send GPS every few seconds into an in-memory geo index (for example Redis GEOSEARCH). The matcher asks for free drivers within 3 km, gets about 10 in milliseconds, then re-ranks them by real drive-time ETA.

    Which database should a taxi app use?

    Two kinds. Live positions go in an in-memory store with an expiry (Azure Managed Redis). Trips, users and payments go in a durable, multi-region database such as Azure Cosmos DB, partitioned by city.

    Which Azure services does a taxi booking app need?

    A typical design uses Azure Front Door, API Management, Web PubSub, Event Hubs, Azure Managed Redis, Azure Cosmos DB, Azure Maps and Notification Hubs, with sign-in through Microsoft Entra External ID.

    Do I need microservices from day one?

    No. Start with one service with clear modules (trip, matching, location). Split out location and matching first when load demands it.

    Interview questions

    How this topic comes up in system design interviews. Answer out loud first, then open the model answer.

    beginner What does API Management do in this design?

    Checks tokens, applies rate limits (for example 10 bookings a minute per user) and keeps old API versions alive for old app releases.

    intermediate Why not let driver phones call a REST API for every GPS point?

    At 250k requests a second the API tier becomes huge and expensive. A WebSocket gateway plus a streaming ingest handles it with far fewer servers.

    advanced How does a matched trip reach the rider in real time?

    The trip service publishes to a Web PubSub group for that trip; the rider’s socket is in the group, so the event arrives in under a second. If the app is backgrounded, a push wakes it and the app re-reads the trip.

    Quick revision

    Remember

    • Follow all 16 steps
    • Map each box to Azure
    • Six patterns behind it
    • Build it yourself
    • Use Azure Managed Redis for new designs. Azure Cache for Redis has a retirement timeline for all tiers, so AI tools trained on older code will often suggest the wrong service.

    One line to remember

    “Two paths: a fast lossy stream and a slow exact command road.”

    Official documentation