MSD-101 · Global taxi booking design
The full architecture on Azure
⏱ 15 min 🎮 Hands-on ☁ Azure ✓ Completed
⚡ 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
Each box is one Azure service. Tap a box (or Tab to it) to see its job and why it is there.
Create each resource. The defaults are a good design; change a setting and read why it matters. Some choices decide what breaks later.
Home › Create a resource › Azure Front Door
Create a Front Door profile
ⓘ Premium adds managed WAF rule sets and Private Link to your origins.
ⓘ Blocks common attacks and bad bots at the edge, before they cost you anything.
ⓘ How quickly Front Door notices a sick region.
Deployment in progress…
Microsoft.FrontDoor · resource group rg-global-taxi
Home › Create a resource › Azure API Management
Create API Management service
ⓘ v2 tiers deploy fast and scale; Developer has no SLA and is for testing only.
ⓘ Stops retry storms and bots from crowding out real riders.
ⓘ A backend pool with priority and a circuit breaker fails over when one region is down.
ⓘ Only signed-in users can book.
Deployment in progress…
Microsoft.APIManagement · resource group rg-global-taxi
Home › Create a resource › Azure Container Apps
Create Container App: trip-service
ⓘ Two copies so one crash never stops bookings.
ⓘ Adds replicas when bookings spike (a KEDA scale rule).
ⓘ A managed identity has no key to leak or rotate.
ⓘ A repeated key returns the existing trip instead of creating a new one.
Deployment in progress…
Microsoft.ContainerApps · resource group rg-global-taxi
Home › Create a resource › Azure Web PubSub
Create Web PubSub service
ⓘ Free is for tests; Standard is for production traffic.
ⓘ One unit holds 1,000 concurrent connections; add units as drivers grow.
ⓘ Streams driver GPS straight to Event Hubs, so no web server takes the load.
Deployment in progress…
Microsoft.WebPubSub · resource group rg-global-taxi
Home › Create a resource › Azure Event Hubs
Create Event Hubs namespace
ⓘ Standard supports consumer groups and up to 40 throughput units.
ⓘ 1 unit takes 1 MB/s or 1,000 events/s in.
ⓘ Partition by city so one busy city does not slow the others.
Deployment in progress…
Microsoft.EventHubs · resource group rg-global-taxi
Home › Create a resource › Azure Managed Redis
Create Azure Managed Redis
ⓘ Balanced fits a geo index with many small, fast writes.
ⓘ A driver who stops pinging should stop getting offers.
Deployment in progress…
Microsoft.ManagedRedis · resource group rg-global-taxi
Home › Create a resource › Azure Cosmos DB
Create Azure Cosmos DB account
ⓘ NoSQL fits trip documents and change feed.
ⓘ Spreads trips by city; queries for one city stay in one partition.
ⓘ A replica in the backup region keeps trips safe in an outage.
Deployment in progress…
Microsoft.CosmosDB · resource group rg-global-taxi
Everything is deployed. Your architecture is lit up below. Go to Run to send a request through it.
Request: Priya taps Book: Airport T3 → City centre
⚠️ Front Door Premium, API Management Standard v2, Azure Managed Redis and Event Hubs bill every hour, even with no traffic. Use a test subscription and delete the resource group when you finish.
- Use an Azure free account or a team sandbox subscription, never production.
- Create one resource group, e.g. rg-taxi-lab, in Southeast Asia.
- Create the resources in the order you built them here, with the same settings.
- Give the trip service a managed identity and a Cosmos DB data-plane role instead of a connection string.
- Test with one booking, check the trace in Application Insights, then delete the resource group.
* Illustrative prices to compare designs, not a quote. Check the Azure pricing calculator for real numbers.
What breaks, and the fix
| Failure | User sees | Why | Fix |
|---|---|---|---|
| 🌩️ Region down (Southeast Asia) | “Service unavailable” for the whole country | One region was the only place the trip service ran | Backend pool across two regions + Cosmos DB replica |
| 📶 Network drop, app retries | Two drivers and two card holds | The retry looked like a new booking | Idempotency-Key checked by the trip service |
| 🎆 10× booking spike | Endless spinner, then an error | Fixed capacity | Autoscale + rate limits + an honest high-demand screen |
| 💀 Driver apps killed by the OS | 15 s waits, frozen cars | Dead phones stayed in the index | 30 s expiry on driver positions |
| 🔁 Database key rotated | Nobody can book | A secret in app settings went stale | Managed identity with Cosmos DB data-plane RBAC |
| 🤖 Bot flood on Book | Slow booking, higher bill | Attacks reached the API | Front Door Premium with WAF managed rules |
🎓 Education-only simulation. Nothing is created in Azure and no subscription is needed.
Watch one booking travel through the system. Switch flows with the coloured chips. Tap any box.
Press ▶ Play to watch one booking travel through the system, or tap any box.
GET /trips/{id}.Stream vs command
Live data can lose a point. Commands must happen exactly once. Give them different roads.
GPS points ride the WebSocket every 4 s. One lost? The next one replaces it.
Idempotency key
Send the same ID on every retry. The server returns the first result instead of doing it again.
Book with key k7. The trip is saved… but the reply is lost in the lift.
Outbox + backoff
Save the command on the phone first, then send it. Wait longer after every failure.
The tap is saved to the local outbox. Even if the app dies now, it is not lost.
Geo index + expiry
Keep only the latest position per driver in memory, and let it expire after 30 s.
Every ping overwrites the driver’s last position and resets a 30 s timer.
Pub/sub fan-out
Publish one event to a group. Everyone in the group gets it, however many they are.
The trip service publishes once: “car moved”.
Push to wake, then re-sync
A push only says “something changed”. The app then asks the server for the truth.
The app is in the background, so its socket is closed. The server sends a push.
Six boxes are empty. Each shows what it must do. Put the right Azure service in each.
- 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.
- The design ideaTwo paths: a fast lossy stream and a slow exact command road.
- 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.
| Box | Azure service | Job |
|---|---|---|
| Global entry | Azure Front Door | Route to nearest healthy region |
| API gateway | Azure API Management | Auth, rate limits, versions |
| Live connections | Azure Web PubSub | One WebSocket per open app |
| Location stream | Azure Event Hubs | ≈ 250k events a second |
| Live driver index | Azure Managed Redis | Geo search, 30 s expiry |
| Trips database | Azure Cosmos DB | Durable, multi-region |
| Routes and ETA | Azure Maps | Drive-time ranking |
| Push wake-up | Azure Notification Hubs | Reach backgrounded apps |
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.
Test yourself
5 questions. Get 4 right and this lesson is marked complete.
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
- Web PubSub: send client events to Event Hubs (Microsoft Learn)
- Azure Managed Redis (Microsoft Learn)
- Azure Maps (Microsoft Learn)
- Microsoft Entra External ID (Microsoft Learn)