Guide

Demand for rides is local. A trip in Bangalore never needs data from São Paulo. So the location stream, the geo index and the matchers can all be split by region, or by city. That split limits what one failure can touch, and it makes hot spots easier to handle.

The big idea

Partition the world into regions, cities or cells, and pin each trip to the region of its pickup. Cross-region trips are rare, so they can be handled as exceptions. Each cell has its own index and matchers.

The split also helps with blast radius. A bad deploy in one city stays in that city's cells, the same idea covered in limiting blast radius.

Walking through it

Predictable hot spots. An airport has pickups concentrated in a few curb zones. Drivers queue in holding lots. A naive "nearest driver" may pick someone stuck behind a barrier. The fix is to give airports their own cell pool and matcher capacity. Product rules, such as allowed pickup polygons and walking distance, then sit on top of the same index.

A stadium let-out is a burst. Teams can move drivers ahead of time with incentives, raise surge early, and tighten the match radius, so trips clear the venue's roads faster.

Surge pricing. Each cell records requests per minute and available drivers. Take a cell with 300 requests per minute and 60 available drivers. Its demand-to-supply ratio is 300 ÷ 60 = 5. A multiplier function turns that ratio into a price, with caps, so a spike cannot produce an absurd fare. Hysteresis keeps the multiplier from flipping up and down on small changes. The multiplier is published to an edge cache, and the trip request reads it for its pickup cell.

Trade-off

Surge pricing does two jobs. It raises supply, because drivers move toward the price. It also damps demand, because some riders wait or leave. Hysteresis prevents thrashing, which would confuse both riders and drivers.

Rebalancing. If a cell's demand grows for good, split its shard or add matchers. Rebalancing is a planned change, not an emergency.

Common mistakes

  • Sharding by user ID instead of geography. Matching then has to query many shards for one pickup.
  • No plan for a stadium let-out. The surge arrives faster than drivers can react.
  • Surge with no hysteresis. Prices flip on every small change, and riders stop trusting them.

Check yourself

  1. Why does geographic sharding limit the damage of a bad deploy?

    Answer: the deploy reaches only the cells in one region, so other cities keep matching normally.

  2. Why add hysteresis to a surge multiplier?

    Answer: without it, small changes in supply flip the price up and down, which confuses riders and drivers.

Key takeaways

  • Partition location, index and matching by geography, because demand is local.
  • Give predictable hot spots, such as airports and stadiums, dedicated capacity and early surge.
  • Surge pricing raises supply and damps demand, and it needs caps and hysteresis.
  • Keep cross-region trips as exceptions, and pin trips to their pickup region.

Further learning

The ride-sharing overview ties this page back to the rest of the dispatch design. For the general pattern of splitting data, see sharding.