← All posts

Killing the Google Maps bill: a migration playbook

Paid routing APIs are wonderful — until your volume grows and the invoice becomes a line item leadership asks about. Self-hosting Valhalla or OSRM can turn that variable, per-request bill into fixed, predictable infrastructure. But "rip out Google and drop in OSRM" is how you take down production. Here's the measured path I actually use.

Step 0: Know what you're paying for

Before touching code, break the bill down by endpoint — directions, matrix, geocoding, snapping. Self-hosted routing replaces the routing parts cleanly; geocoding is a separate decision. Knowing the split tells you how much you'll actually save and what you still need to source elsewhere.

Step 1: Stand it up in the shadow

Deploy Valhalla/OSRM on your OSM extract in your own cloud, and put a thin adapter in front that speaks your existing API's shape. Nothing in production changes yet — you're building the replacement quietly alongside the real thing.

Step 2: Parity-test against real traffic

This is the step teams skip and regret. Mirror a sample of real requests to the new engine and diff the results — distance, duration, geometry. You're not looking for identical numbers (the road data and costing differ); you're looking for explainable differences and no nasty surprises.

Trust is earned in the diff. Ship the migration when the deltas are boring, not when the code compiles.

Step 3: Model the real cost

  • Before: per-request API spend at current + projected volume.
  • After: compute, storage, and the data-refresh pipeline — plus the one-time migration effort.

For most teams at scale the crossover is dramatic, and it improves as you grow, because self-hosted cost is driven by infrastructure, not by call count.

Step 4: Cut over gradually

Route a small percentage of traffic to the new engine behind a flag. Watch latency, error rates and business metrics. Ramp 1% → 10% → 50% → 100%, keeping the old provider as an instant rollback until you're confident. No big-bang, no 3am surprises.

Step 5: Own the pipeline

The engine isn't "done" once it's live — OSM data ages. Automate PBF extracts, tile/graph rebuilds and zero-downtime swaps so your map stays fresh without anyone babysitting it. That pipeline is what turns a migration into a system you own.

That's the whole playbook: shadow, parity, cost, gradual cutover, own the pipeline. Want it run end-to-end for your stack? Let's talk.