MSD-101 · Global taxi booking design
What breaks, and how the design survives
⏱ 12 min 🎮 Hands-on ☁ Azure ✓ Completed
⚡ The 30-second answer
Good mobile designs are judged by what happens when things fail. A taxi app must survive network drops mid-request (idempotency + outbox), expired tokens (silent refresh, replay once), killed driver apps (location expiry, honest status), region outages (Front Door failover) and surges (queue + autoscale).
- Five failures every ride app meets
- What the user sees
- The fix for each
- Prove it in the playground
Try it
Play with the design before you read about it. Everything runs on this page.
Pick a failure. Watch it without the fix, then with it.
Result: The first request did arrive. Two trips, two drivers, two card holds.
- Command saved in the outbox with key
bk_7f3a… - Retry after 1 s, 2 s, 4 s (max 5 tries)
- Server sees the same key and returns the existing trip
Result: One trip. The retry carried the same idempotency key, so the server returned the trip it already made.
Result: API Management returns 401 and the app treats it as “logged out”.
- Get 401 → one refresh call with the refresh token
- Hold other calls until the new token arrives
- Replay the failed call once; log out only if refresh fails
Result: The app refreshed the token in the background and replayed the call once.
Result: The last position stays forever, and matching keeps offering trips to a phone that is off.
- Android foreground service and iOS background location keep GPS alive on a trip
- Redis entry expires after 30 s, so no offers go to a dead phone
- Push asks the driver to reopen the app; trip is reassigned after 2 minutes
Result: The position expires after 30 s, matching skips the driver, and the rider sees an honest status.
Result: One region was the only place the app could reach.
- Front Door health probes mark region A unhealthy
- Traffic goes to region B; Cosmos DB has a replica there
- Redis refills itself within one 4 s ping cycle
Result: Front Door moved traffic to region B. Trips were already replicated, and the driver index refills from the next GPS pings.
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.
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.
- The problemOn New Year’s Eve at 00:05, bookings jump tenfold, a region has a network issue, and half the drivers’ phones are on 5% battery. The on-call engineer has 30 minutes.
- The design ideaPlan the failure before you write the happy path.
- In real lifeTeams that run game days (breaking things on purpose in a test environment) find most of these problems before their users do. The playground on this page is a small game day.
Start with a question
On New Year’s Eve at 00:05, bookings jump tenfold, a region has a network issue, and half the drivers’ phones are on 5% battery. The on-call engineer has 30 minutes.
Every one of those failures is predictable. The design decides whether users notice.
Explain it like I'm 10
A good school bus plan says what to do if it rains, if a bus breaks down, or if the road is closed. You do not wait for the rain to make the plan.
The technical explanation
Network drops mid-booking. Save the command in the outbox with an idempotency key, retry with backoff (1, 2, 4, 8 s, max 5), and let the server return the existing trip for a repeated key.
Token expires mid-trip. On a 401, refresh once with the refresh token, hold other calls, replay the failed call once, and log out only if the refresh fails.
Driver app killed. The driver’s Redis entry expires after 30 s, so matching skips them; the rider sees “location paused, last seen 20 s ago”; the trip is reassigned after 2 minutes.
Region down or 10× surge. Front Door moves traffic to another region; Cosmos DB has a replica there and Redis refills from the next pings. For surges, queue booking commands, autoscale Container Apps on load, rate-limit per user and show an honest “high demand” screen.
| Failure | User sees without the fix | The fix |
|---|---|---|
| Network drop | Two drivers, two charges | Idempotency key + outbox |
| Token expiry | Logged out mid-ride | Refresh once, replay once |
| App killed | Frozen car on the map | 30 s expiry + honest status |
| Region down | “Service unavailable” | Front Door failover |
| 10× surge | Endless spinner | Queue + autoscale + rate limit |
Real-world scenario
Teams that run game days (breaking things on purpose in a test environment) find most of these problems before their users do. The playground on this page is a small game day.
Test yourself
5 questions. Get 4 right and this lesson is marked complete.
Pass the quiz to complete this lesson.
Next: AI inside the app, and AI-written code →Questions people ask
What happens to a taxi app when an Azure region goes down?
Azure Front Door health probes move traffic to a healthy region. Cosmos DB already has a replica there, and the Redis driver index refills from the next GPS pings, so riders can keep booking.
How should a mobile app retry a failed request?
Reuse the same idempotency key, wait longer each time with jitter (1, 2, 4, 8 s) and stop after about 5 tries in a state the user can see. Fast, endless retries drain the battery and cause a retry storm.
What should the app show when the backend is down?
An honest status (“We are having trouble, your request is saved”), keep the command in the outbox, retry in the background with backoff, and never ask the user to tap again.
Interview questions
How this topic comes up in system design interviews. Answer out loud first, then open the model answer.
beginner What is an idempotency key?
A unique ID the client sends with a command and reuses on every retry, so the server can return the first result instead of doing the work twice.
intermediate How do you avoid a retry storm after an outage?
Exponential backoff with jitter on the client, a maximum number of tries, rate limits in API Management, and a queue in front of the expensive work.
advanced How would you test these failures before launch?
Game days in a staging region: cut network on test phones, expire tokens early, kill driver apps, fail a region with Front Door, and load-test 10× traffic, checking the user-facing screens and the metrics each time.
Quick revision
Remember
- Five failures every ride app meets
- What the user sees
- The fix for each
- Prove it in the playground
- Every retry loop needs three things: the same idempotency key, a growing wait with jitter, and a maximum number of tries that ends in a state the user can see.
One line to remember
“Plan the failure before you write the happy path.”
Official documentation
- Azure Front Door (Microsoft Learn)
- Azure Service Bus (Microsoft Learn)
- Azure Well-Architected Framework: reliability (Microsoft Learn)