How a routing engine turns a map into the fastest path — from the OpenStreetMap extract to the tricks Google Maps and commercial routers lean on. Read straight from the source.
A RumitX from-the-source handbook on OSRM (Open Source Routing Machine), the open, canonical road-routing engine behind a great deal of the world's mobility and logistics tooling. It takes you from an OSM extract → the edge-based graph → Contraction Hierarchies and Multi-Level Dijkstra → map matching → what the elite routers actually optimize — grounded in one pinned repo, read beside your own routing service. English is the default edition; a Vietnamese edition renders in parallel.
Keep the English keywords — they are the language of the domain, the source, and the search box.
Backend, mobility, and logistics engineers who have called a /route/v1/driving/... endpoint (or a Directions API) and want to understand everything underneath it: why a continent-sized shortest-path query returns in milliseconds, why the graph is "edge-based," why live traffic can update in seconds on one setup and needs a full rebuild on another, and why a raw GPS trace snaps cleanly onto the road. You should be comfortable reading modern C++ and unbothered by a little Lua (the profiles); no GPU or special hardware is required. A laptop with Docker (or a C++ toolchain) and a small OSM extract is enough for every lab.
| Role | Repo | Pin (tag @ SHA) |
|---|---|---|
| The open, canonical road-routing engine — extract, contract, partition, customize, query | Project-OSRM/osrm-backend |
v26.7.3 @ 0844e3a |
⚠️ Straight talk about the closed parts. The routing you consume from Google Maps / Google Directions — and the live-traffic feeds most commercial routers run on — are closed-source. This book never pretends to read them. It teaches OSRM, the open engine the industry actually forks and self-hosts, and names the open alternatives (Valhalla, GraphHopper) where they take a different design. Chapter 07 keeps an honesty ledger of every claim about the closed routers that is inferred from public engineering writing rather than read from source.
- Why it matters — the problem this layer solves.
- Mental model + ASCII diagram — a picture to hold in your head.
- Guided source read — exact
file:linecitations into the clone. - Lab — concrete commands you run against a real OSRM instance, with a stated expected result — often beside your own service.
- Checkpoint — 4–6 questions; "if #X is shaky, re-read §N.Y".
- Next — the link onward.
Depth is weighted toward Chapter 03 (the routing core) — that is where the magic actually happens, and it carries four case studies.
| # | Chapter | Tier |
|---|---|---|
| 00 | Environment & the Routing Toolbox | Foundation |
| 01 | Mental Model & the Pipeline | Foundation |
| 02 | Graph Extraction & the Profile | Foundation |
| 03 | ★ The Routing Core: CH & MLD | Flagship |
| 04 | The Engine Plugins & the API | Core |
| 05 | Map Matching & Trip Services | Core |
| 06 | Weights, Turn Penalties & Customization | Application |
| 07 | What Production Routing Optimizes | Application |
| 08 | Capstone & Staying Current | Mastery |
Suggested pace: ~1 chapter per sitting; spend two on Chapter 03. About two weeks part-time.
- 00 — Cloned + pinned the repo; ran extract → partition → customize → routed; got a
/routeJSON back. - 01 — Can draw the pipeline and trace one
/routerequest from URL to JSON. - 02 — Can explain node-based vs edge-based, and point to where the transformation happens.
- 03 — Can explain the query graph, CH contraction, the bidirectional CH query, and MLD.
- 04 — Can read the plugin base and name what each service (route/table/trip/nearest/match/tile) does.
- 05 — Can explain HMM emission/transition and trace a trace into a matched path.
- 06 — Can explain why MLD customize re-weights without re-partitioning, and run the updater.
- 07 — Can name the elite optimizations and which open mechanism each maps to.
- 08 — Stood up a live-traffic service; read a real OSRM PR unaided.
osrm-book/
├── README.md # this file
├── 00..08-*.md # 9 chapters (English, canonical)
├── 00..08-*.vi.md # 9 chapters (Vietnamese siblings)
├── labs/ # lab-note templates + a minimal runnable artifact
├── diagrams/ # placeholder
├── reference/glossary.md # terms + a "Key files" source index (+ .vi.md)
├── site_src/ # engine.py (shared), book.py (per-book), build_site.py (shim)
└── site/ # built output: site/*.html (EN) + site/vi/*.html (VI)
Build the site (22 pages + 2 handbook.html):
python3 site_src/build_site.pyA RumitX publication · how a routing engine finds the path, from the source.