API Maker

The backend engine for the AI era

Case study 08 · Real-time & WebSockets

Live tracking for 40,000 grocery orders a day

FreshDash delivers groceries in 30 minutes across Riyadh and Jeddah. Customers want to watch the rider come, and dark stores want to see an order the second it lands. FreshDash replaced polling with the WebSockets and events of API Maker, and the live map now updates in under 200 ms at the evening peak.

  • <200 msfrom rider GPS to the customer's mapwas 10 seconds of polling
  • 22,000live connections at 8 pmon 3 servers
  • −83%requests at the evening peak2,050 → 350 a second
  • −27%"Where is my order?" chatsin three months

The challenge

Where FreshDash was stuck

FreshDash promises groceries in 30 minutes. For a customer waiting at the door, the most opened screen of the app is the map with the rider on it. Until 2025 that map asked the server every 10 seconds where the rider was. With 20,000 open screens at 8 pm, that was 2,000 requests a second asking the same question, and mostly getting the same answer.

The dark stores had the same problem the other way round. Their tablets refreshed the list of orders every 15 seconds, so a new order could wait 15 seconds before anyone started picking it. In a 30-minute promise, that is a long time.

  • Polling at scaleOpen maps and store tablets asked for news on a timer: 2,000 requests a second at peak, most of them for nothing.
  • A map that jumpedThe rider moved in jumps of 10 seconds, so customers opened a chat to ask where the order was.
  • Lost seconds in the storeA new order waited up to 15 seconds before the store saw it.

The solution

What they built with API Maker

The catalog APIs of FreshDash already ran on API Maker. Its WebSockets and events were the missing piece: the server tells the screens when something changes, instead of the screens asking. The rider app keeps posting its location, and the server pushes it to the people who watch that order, and to nobody else.

  1. The rider location as an event

    The rider app posts its GPS every 3 seconds. A listener checks the order and sends the location on as a custom WebSocket event.

    Events & Listeners
  2. Pushed only to the right screens

    Each customer screen registers for that event with a condition on its own order. A location reaches the customer and the store of that order: 2 screens, not 22,000.

    WebSockets
  3. New orders land on the tablet

    Store tablets register for the orders API with a condition on their store. When an order is paid, its store hears about it at once.

  4. Late riders found in time

    A scheduler checks every minute for orders running late, and alerts the store lead before the customer notices.

    Schedulers
  5. Spread over three servers

    Three API Maker servers share the connections behind a load balancer. Redis carries the messages between them, so a location posted to one server reaches a screen held by another.

The numbers

Before and after

Requests a second during the evening peak

  • Polling, before
  • WebSockets, now
05001,0001,5002,0002,5005 pm6 pm7 pm8 pm9 pm10 pm11 pm5 pm, Polling, before: 8206 pm, Polling, before: 1,2407 pm, Polling, before: 1,6908 pm, Polling, before: 2,0509 pm, Polling, before: 1,88010 pm, Polling, before: 1,32011 pm, Polling, before: 6405 pm, WebSockets, now: 1406 pm, WebSockets, now: 2107 pm, WebSockets, now: 2908 pm, WebSockets, now: 3509 pm, WebSockets, now: 32010 pm, WebSockets, now: 23011 pm, WebSockets, now: 110820640140110
05001,0001,5002,0002,5005 pm6 pm7 pm8 pm9 pm10 pm11 pm5 pm, Polling, before: 8206 pm, Polling, before: 1,2407 pm, Polling, before: 1,6908 pm, Polling, before: 2,0509 pm, Polling, before: 1,88010 pm, Polling, before: 1,32011 pm, Polling, before: 6405 pm, WebSockets, now: 1406 pm, WebSockets, now: 2107 pm, WebSockets, now: 2908 pm, WebSockets, now: 3509 pm, WebSockets, now: 32010 pm, WebSockets, now: 23011 pm, WebSockets, now: 110820640140110

The same evening of the week, one month apart, with 9% more orders.

Time for a change to reach the screen (seconds, worst case)

  • Polling
  • WebSockets
051015Rider on the map, Polling: 10 s10 sRider on the map, WebSockets: 0.2 s0.2 sRider on the mapNew order in the store, Polling: 15 s15 sNew order in the store, WebSockets: 0.15 s0.15 sNew order in the storeOrder status, Polling: 10 s10 sOrder status, WebSockets: 0.18 s0.18 sOrder status
051015Rider on the map, Polling: 10 s10 sRider on the map, WebSockets: 0.2 s0.2 sRider on the mapNew order in the store, Polling: 15 s15 sNew order in the store, WebSockets: 0.15 s0.15 sNew order in the storeOrder status, Polling: 10 s10 sOrder status, WebSockets: 0.18 s0.18 sOrder status

Measured on the 95th percentile of the evening peak.

The results

What changed for FreshDash

  • A map that movesRiders glide on the map instead of jumping, and the location shown is never more than 3 seconds old.
  • Less traffic, more roomPeak requests fell by 83%. The three servers carry 22,000 connections at under 40% CPU.
  • Fewer worried customers"Where is my order?" chats fell by 27% in three months.
  • Picking starts soonerStores see a new order in under a second, and the average time to dispatch fell by 2 minutes.
Our customers do not read our delivery time, they watch the rider. Since the map moves smoothly they trust it, and they stopped writing to support to ask.
VP EngineeringFreshDash

What comes next. FreshDash is adding live stock: when a store runs out of an item, the apps of the customers around it will hide the item within a second.

Have a problem like FreshDash?

Try API Maker on your own computer for free, or tell us about your project.