← Lessons

quiz vs the machine

Platinum1880

System Design

The Dispatch Matching Algorithm

Pairing waiting requests with available supply to optimize the whole system, not one trip.

6 min read · advanced · beat Platinum to climb

Greedy is not enough

The simplest dispatch grabs the nearest available driver for each request as it arrives. This greedy choice is locally fine but globally poor: assigning a driver to a far request can strand a closer request that arrives a moment later, raising total wait time.

Batched assignment

Better systems batch requests and drivers over a short window and solve an assignment problem that minimizes a global cost like total wait or pickup distance. This is a matching over a cost matrix where each cell is the cost of pairing a request with a driver.

Real world constraints

  • Filter first. Use proximity search so each request only considers nearby drivers, keeping the matrix small.
  • Mix objectives. Balance rider wait, driver utilization, and fairness, not distance alone.
  • Act fast. The window is tiny, so the solver must return within the latency budget, falling back to greedy under overload.

Key idea

Dispatch matching batches requests and drivers to solve a global assignment that minimizes total cost, beating per request greedy nearest choices.

Check yourself

Answer to earn rating on the learn ladder.

1. Why is always picking the nearest driver per request suboptimal?

2. What does batched dispatch solve?

3. How is the cost matrix kept small?