20. Uber — geospatial sharding and workflow durability
One-liner. Shard by geography for dispatch, and make long-running workflows durable.
Context. Match riders and drivers in seconds, in hundreds of cities, with trips that outlive any single request.
Public architecture (engineering blog).
- H3 hexagonal geospatial index buckets drivers/requests; dispatch is sharded by city/area, not by user.
- Schemaless (2014) was a sharded MySQL key-value store for trip data, with immutable cells and versioned rows.
- Cadence (now Temporal's lineage) runs durable workflows: trip lifecycle, payments, notifications, with retries and timers.
- Kafka carries events; Pinot serves OLAP dashboards; Michelangelo handles ML features.
Design lesson. The shard key should be the coordination boundary (city), not the entity (user). And anything with timers/human steps belongs in a workflow engine, not a request handler.
Trade-off. Geo sharding creates hot cities and cross-shard trips (airport → city); the workflow layer absorbs the boundary crossing.
Trap. Implementing trip state as a chain of HTTP calls — no retries, no timers, lost state on deploy. Do this. Model long-lived processes as workflows with explicit state.
Why is dispatch sharded by city/area instead of by rider ID?
The hot query is "find nearby drivers", which is spatial; sharding by geography keeps it local.