Updated 24 October 2026
Dispatch and marketplace matching
How ride-hailing, delivery and services marketplaces assign supply to demand: location indexing, candidate selection by ETA, greedy versus batched matching, offers and acceptance timeouts, preventing double assignment, batching orders, and the metrics that matter.
Try it yourself, in a playground:MatchmakingDispatch matchingSurge pricing
Uber assigns drivers to riders, DoorDash assigns couriers to orders, and services marketplaces assign professionals to jobs. Each runs a dispatch system: a loop that continuously matches moving supply to incoming demand, under time pressure, without ever assigning the same driver twice. It is the heart of every marketplace design question.
The inputs
- Supply: drivers or couriers with live locations (updated every few seconds), status (available, on trip, offline), vehicle type and ratings.
- Demand: requests with pickup and drop-off locations, requested product, time constraints (food ready time, scheduled job).
- Road network for travel times. See routing and shortest paths.
Tracking supply
Location updates arrive at high rates (a million drivers updating every 4 seconds is 250,000 writes per second). Keep current locations in memory, indexed by a geospatial grid (geohash, S2 or H3 cells), partitioned by city or region. Persist the location history asynchronously for analytics and trip records. See geospatial and proximity.
Candidate selection
For a new request:
- Look up available supply in the surrounding cells, expanding outward until there are enough candidates.
- Compute ETAs from each candidate to the pickup with the routing engine (straight-line distance is a poor proxy in cities with rivers and one-way streets).
- Filter by constraints (vehicle type, ratings, capacity).
Greedy versus batched matching
- Greedy: assign each request immediately to the best available candidate (lowest ETA). Simple and fast, but locally optimal choices can be globally bad: taking the nearest driver for rider A may leave rider B with a 15-minute wait.
- Batched: collect requests and available supply for a short window (a few seconds), then solve an assignment problem that minimises total ETA (or maximises a broader objective) across all pairs. Better overall outcomes for a few seconds of delay.
Large marketplaces use batched matching in dense areas and greedy matching where supply is sparse.
Offers and acceptance
Drivers can decline. The flow:
- Send an offer to the chosen driver with a timeout (10 to 20 seconds).
- Reserve the driver during the offer so no other request can claim them.
- On accept, confirm the trip; on decline or timeout, release the driver and try the next candidate.
Track acceptance rates; repeated declines and long timeouts hurt rider wait times.
Never assign twice
Two dispatchers (or two requests in parallel) must not claim the same driver. Options:
- Single writer per region: one dispatch process owns each city's state, serialising decisions. Simple and fast; partition big cities into zones.
- Atomic claim: compare-and-set on the driver's status (
availabletooffered, with an offer id). Losing claimants move to the next candidate.
See distributed locks and leases.
Delivery specifics
Food delivery adds:
- Ready time: dispatch the courier so they arrive when the food is ready, not too early (waiting) or late (cold food).
- Batching orders: one courier carries two orders from nearby restaurants to nearby customers, which increases efficiency at a small delay cost.
- Three-sided timing between customer, restaurant and courier.
See Design DoorDash.
Services marketplaces
For plumbers or cleaners, matching uses skills, ratings, availability calendars and price as well as distance, and offers may go to several providers at once (first to accept wins, with atomic claiming). See Design Contractor Matching.
Balancing supply and demand
When demand exceeds supply, matching alone cannot help; pricing and incentives move supply. See surge and dynamic pricing.
Metrics
- Time to match and pickup ETA (riders).
- Utilisation and idle time between trips (drivers).
- Acceptance and cancellation rates.
- Unfulfilled requests.
- ETA accuracy.
Changes to dispatch logic are evaluated with switchback experiments, because riders and drivers in the same area affect each other. See feature flags and A/B testing.
In the interview
For Design Uber: in-memory location index per region, candidates from nearby cells ranked by routing ETA, batched matching in dense areas, offers with timeouts and atomic driver claims, and per-region single-writer dispatch for consistency.
Checklist
- In-memory geospatial index of supply, partitioned by region.
- Candidates by real ETA, not straight-line distance.
- Greedy or batched assignment depending on density.
- Offers with timeouts; reservation during offers.
- Single writer or atomic claims to prevent double assignment.
- Delivery: ready-time aware dispatch and order batching.
- Matching metrics and switchback experiments.
Questions people ask
What is a dispatch system?
A dispatch system is a loop that continuously matches moving supply to incoming demand, such as drivers to riders or couriers to orders, under time pressure and without ever assigning the same driver twice. Ride-hailing, food delivery and services marketplaces each run one, and it is the heart of every marketplace design question. Its inputs are live supply locations and status, requests with pickup and drop-off locations, and the road network for travel times.
What is the difference between greedy and batched matching?
Greedy matching assigns each request immediately to the best available candidate, while batched matching collects requests and supply for a few seconds and solves an assignment problem across all pairs. Greedy is simple and fast but can be globally bad: taking the nearest driver for rider A may leave rider B with a 15-minute wait. Batching gives better overall outcomes for a few seconds of delay, so large marketplaces batch in dense areas and match greedily where supply is sparse.
How does a ride-hailing app match drivers to riders?
It keeps available drivers in an in-memory geospatial index per region, finds candidates in the cells around the pickup, ranks them by routing ETA, and offers the trip to the best one. Locations arrive at high rates (a million drivers updating every 4 seconds is 250,000 writes per second), so current positions live in memory in geohash, S2 or H3 cells. Real ETAs matter because straight-line distance is a poor proxy in cities with rivers and one-way streets.
How do you prevent assigning the same driver twice?
Give each region a single writer, or claim drivers atomically. With a single writer, one dispatch process owns each city's state and serialises decisions, with big cities split into zones. With an atomic claim, a compare-and-set moves the driver's status from available to offered with an offer id, and losing claimants move to the next candidate. The driver stays reserved during the 10 to 20 second offer, then is released on decline or timeout.
How is food delivery dispatch different from ride-hailing?
Food delivery adds ready time, order batching and three-sided timing between customer, restaurant and courier. The courier should be dispatched to arrive when the food is ready, not too early (waiting) or too late (cold food). One courier can also carry two orders from nearby restaurants to nearby customers, which increases efficiency at a small delay cost.
What metrics matter for marketplace matching?
The key metrics are time to match and pickup ETA for riders, utilisation and idle time between trips for drivers, acceptance and cancellation rates, unfulfilled requests and ETA accuracy. Changes to dispatch logic are evaluated with switchback experiments, because riders and drivers in the same area affect each other. When demand exceeds supply, matching alone cannot help, and pricing and incentives are what move supply.