Tuesday, May 10, 2022

Delivery time forecast improvements

Now we are moving towards ensuring that JIT (Just In Time) works everywhere - a mechanism for minimizing the time that a courier spends in a restaurant. To do this, the guys from the team of auto-assigning couriers to orders use our forecasts for coming to the restaurant and picking up the order. They try to find the most suitable courier depending on the restaurant's cooking time. By this we want to minimize the waiting time for the courier in the restaurant.


How to control all this?


If we talk about metrics, then we had several tasks:


  • Improve the forecast accuracy metric. It shows how accurate the forecast is relative to the fact.
  • Improve the delays share metric. This is the percentage of orders with early and late arrivals of couriers.
  • Reduce forecast error. This is a metric that correlates with forecast accuracy.
  • Reduce time to market. Many of you probably know this metric — it’s the time to deliver features to production.


Of course, we would not be able to control all this without metrics in Grafana. We love various graphs and metrics very much and decided to build some graphs that show how the forecast behaves in real time.

Mechanism for recalculating delivery time forecasts

There may be cases when the order is canceled or reassigned to another courier. Then we also apply the mechanism for recalculating forecasts.


Kafka helps us calculate dynamic time and reading events from the topic on order status changes.


We also know how to batch orders: this is when client #2 made an order in the same restaurant as client #1. If both are close to each other, then we take into account the forecast for client #2, based on the forecast for client #1.


Recently, our service has changed a bit, now it stores the state for each moment of time along the courier route. That is, using the API, you can get the current label of the courier as part of his order route. This is a kind of courier-tracker, only within the framework of current orders. Now this functionality is used only by the auto-assignment of orders to the courier service. The service receives information about the location of the courier in order to choose the most appropriate moment for assigning the next order.

Delivery time forecast improvements

Now we are moving towards ensuring that JIT (Just In Time) works everywhere - a mechanism for minimizing the time that a courier spends in a...