Skip to main content

Real architecture · Mid

Instacart: shopper routing

Real production architecture. Key points: learned layout and ML + operations research.

15 min read · Source: Instacart · Content reviewed on October 23, 2026

Short answer

Real production architecture. Key points: learned layout and ML + operations research. Instacart delivers groceries and takes on the challenge of completing each delivery on time and with the right products.

01 · CONTEXT

Delivering groceries on time

Instacart delivers groceries and takes on the challenge of completing each delivery on time and with the right products.

Over a few hours there are thousands of orders to deliver, and doing this efficiently is the job of logistics systems. This case is based on a 2017 post written by a former VP of Data Science at the company, which describes a classic optimization problem combined with machine learning.

02 · THE PROBLEM

From TSP to SCVRPTWMT

The simplest formulation is a traveling salesman problem in which the shopper must go to the store first. With a fleet, each shopper receives a batch of orders to buy and then deliver in sequence, and the problem becomes a VRP, which generalizes the TSP.

Exact algorithms exist for TSP up to tens of thousands of deliveries, and even with millions of deliveries heuristics land within 2–3% of optimal.

VarianteWhat it adds
TSPThe shopper must go to the store first.
VRPA fleet of shoppers, each with a batch of orders delivered in sequence.
VRPTWNarrow delivery windows, so only part of the assigned routes is feasible.
Capacitado (C)Large or small vehicles, club cards, and alcohol orders differ among shoppers.
Multiple trips (MT)Each vehicle can make more than one trip.
Stochastic (S)New orders, shifts, and events such as weather and traffic change the plans.

The sum of all the constraints is described in the post as an SCVRPTWMT.

03 · FROM GREEDY TO NEW

The fulfillment engine

The starting point was a variation of a greedy algorithm: sort orders by deadline, find the free shopper who can do the first order fastest, look for orders that fit without delay, and dispatch.

Since then the company has introduced new approaches, with a large impact on speed. In the post, minutes per delivery in San Francisco were cut in half, without compromising late deliveries or order quality.

  1. One of the changes is to decompose the problem into subproblems, and one of them is batching deliveries.

    Architecture diagram: Instacart: fulfillment engine
    CLCustomer app
    CPDelivery batchingbatches deliveries
    CPTime prediction (ML)
    CPSearch heuristics
    CPShopper assignment
    CPDespacho
    CLShopper app
  2. A machine learning model predicts the expected time distribution for each combination of shopper and assignment.

    Architecture diagram: Instacart: fulfillment engine
    CLCustomer app
    CPDelivery batching
    CPTime prediction (ML)time prediction
    CPSearch heuristics
    CPShopper assignment
    CPDespacho
    CLShopper app
  3. Another subproblem is shopper assignment; the subproblems are solved nearly to optimality.

    Architecture diagram: Instacart: fulfillment engine
    CLCustomer app
    CPDelivery batching
    CPTime prediction (ML)
    CPSearch heuristics
    CPShopper assignmentassigns orders
    CPDespacho
    CLShopper app
  4. Heuristics limit the search space, handle anomalies, refine the solutions, and help adapt to uncertainty.

    Architecture diagram: Instacart: fulfillment engine
    CLCustomer app
    CPDelivery batching
    CPTime prediction (ML)
    CPSearch heuristicsheuristics
    CPShopper assignment
    CPDespacho
    CLShopper app
  5. The batch plan is recalculated every minute and the dispatch decision is made at the right time.

    Architecture diagram: Instacart: fulfillment engine
    CLCustomer app
    CPDelivery batching
    CPTime prediction (ML)
    CPSearch heuristics
    CPShopper assignment
    CPDespachoat the right time
    CLShopper app

04 · THE SURROUNDING SYSTEM

The engine is just one piece

The application that decides which orders each shopper handles is the fulfillment engine, but it is only one component of the logistics system, which also predicts demand and behavior, manages capacity and peak pricing, and plans the schedule.

  1. The fulfillment engine is only one of the components of the logistics system.

    Architecture diagram: Instacart: logistics systems
    CPFulfillment engineone component
    CPDemand and behavior forecasting
    CPCapacity and peak pricing
    CPSchedule planning
    CPJoint simulation
  2. Another component predicts demand and shopper behavior.

    Architecture diagram: Instacart: logistics systems
    CPFulfillment engine
    CPDemand and behavior forecastingpredictions
    CPCapacity and peak pricing
    CPSchedule planning
    CPJoint simulation
  3. Another manages capacity and peak pricing.

    Architecture diagram: Instacart: logistics systems
    CPFulfillment engine
    CPDemand and behavior forecasting
    CPCapacity and peak pricingcapacidade
    CPSchedule planning
    CPJoint simulation
  4. Another plans and adapts the shopper schedule.

    Architecture diagram: Instacart: logistics systems
    CPFulfillment engine
    CPDemand and behavior forecasting
    CPCapacity and peak pricing
    CPSchedule planningescala
    CPJoint simulation
  5. The systems are highly interdependent, and the company increasingly uses simulations to optimize them together.

    Architecture diagram: Instacart: logistics systems
    CPFulfillment engine
    CPDemand and behavior forecasting
    CPCapacity and peak pricing
    CPSchedule planning
    CPJoint simulationsimulation

05 · GPS DATA

Seeing the system with location data

To optimize shopper assignment and routing, and to communicate with consumers, Instacart collects a GPS data stream stream. Roughly every 10 seconds, the device reports timestamp, latitude and longitude, speed, direction, and accuracy, and the whole adds up to tens of millions of updates per day across the country.

  1. The shopper's device periodically reports timestamp, position, speed, direction, and accuracy.

    Architecture diagram: Instacart: GPS flow
    CLShopper appupdates
    CPLocation collection
    CPFulfillment engine
    CLCustomer app
    CPAnalysis with datashader
  2. The platform collects this stream of location data.

    Architecture diagram: Instacart: GPS flow
    CLShopper app
    CPLocation collectionGPS stream
    CPFulfillment engine
    CLCustomer app
    CPAnalysis with datashader
  3. Location is used to optimize shopper assignment and routing.

    Architecture diagram: Instacart: GPS flow
    CLShopper app
    CPLocation collection
    CPFulfillment engineassignment and route
    CLCustomer app
    CPAnalysis with datashader
  4. The data is also used to communicate well with consumers.

    Architecture diagram: Instacart: GPS flow
    CLShopper app
    CPLocation collection
    CPFulfillment engine
    CLCustomer appcommunication
    CPAnalysis with datashader
  5. Datashader turns millions of points into visualizations that generate hypotheses and confirm changes in production.

    Architecture diagram: Instacart: GPS flow
    CLShopper app
    CPLocation collection
    CPFulfillment engine
    CLCustomer app
    CPAnalysis with datashadervisualization
Data sliceWhat the visualization reveals
AccuracyAccuracy is worse in the financial district, where tall buildings obstruct GPS, and the signal is lost inside stores.
VelocidadeShoppers move faster on highways and slower in the financial district.
DirectionThe layout of the city's streets becomes visible.
Origin storeShows which stores deliver frequently in each neighborhood.
Shopper stateLets you see what the shopper does inside the store, when the measurement is accurate enough.

In short, the case combines optimization with real constraints, machine learning to estimate times, and field data to analyze the system.

Frequently asked questions

What is Instacart: shopper routing?

Real production architecture. Key points: learned layout and ML + operations research.

What does the Instacart: shopper routing design cover?

It is organized in these sections: Delivering groceries on time, From TSP to SCVRPTWMT, The fulfillment engine, The engine is just one piece, and Seeing the system with location data.

How long is Instacart: shopper routing and what level is it?

It takes about 15 minutes to read and is rated Mid level.

Now design it yourself

Run this case as an interview in the System Design school: you make the decisions, the tutor challenges them and you see how your design scores.