Read this story as text
Live order tracking: the story, written out
The rider's dot moves on your map and says arriving in 6 minutes. Nami, a cloud architect, builds the serverless AWS setup behind it: API Gateway, Kinesis, Lambda, DynamoDB, WebSockets, Amazon Location and SNS.
- How does a rider's dot move on your phone, when your phone never asks where he is?
- Twenty thousand riders. A new location every four seconds. Every customer sees only theirs, instantly.
- Three rules we must not break: Thousands of riders send their location every few seconds. Each customer sees only their own rider, right away. The dot keeps moving on a weak network.
- Stay till the end: the dot has a secret. Scroll.
- A phone that knows where it is. One tiny message: the rider's phone knows where he is. How does it find one screen, out of a million?
- A door that takes thousands of pings. Twenty thousand riders, a ping every four seconds: five thousand requests a second. API Gateway takes them all, no server to size. But where do they go next?
- Buffer first, think later. Not a database. That melts at eight pm. Each ping drops into a Kinesis stream: a buffer, ordered by rider. Who reads it?
- Keep only the latest spot. A function keeps only the newest ping per rider, overwriting one row. Old routes? Thrown away. But customers want a number, not just a dot.
- How long until it arrives? Asking for the time left on every ping would cost a fortune. So we ask Amazon Location only after a hundred metres. Now, the customer.
- A phone call that stays open. Your phone opens a WebSocket: a call that stays open. A function saves which connection watches which order. So what makes the dot move?
- Push, do not poll. Here is the magic. When the rider's row changes, a stream wakes a function, and it pushes the new spot down your connection. The server speaks first. But pocket the phone?
- The app in your pocket. The connection dies. So for big moments, picked up, arriving, at your door, we send a normal notification. 'Rider outside' is essential. And when you return?
- Reconnecting without a gap. On reconnect we instantly send the latest position. No stale dot. Now, the secret I promised.
- Make the dot glide. A ping every four seconds would make the dot jump. So the phone slides between pings. The server sends facts, the phone makes the magic. One last question.
- When the rider goes quiet. What if the rider loses signal? A frozen dot lies. After a minute we say 'last seen'. Honest beats smooth. And how do we know it works?
- Watch the stream. One number: how far behind the stream reader is. Thirty seconds late means a thirty second old dot. That is my alarm. Ready?
- The whole picture. That is one ping, phone to screen. Trace it yourself, or open the full diagram.
More stories on Real-world systems