ConfigsJul 3, 2026·3 min read

OSRM — High-Performance Open Source Routing Engine

OSRM computes shortest paths on road networks using OpenStreetMap data, delivering sub-second route calculations for driving, cycling, and walking.

Agent ready

Review-first install path

This asset needs a review step. The copied prompt tells the agent to dry-run, show the writes, then proceed only after confirmation.

Needs Confirmation · 64/100Policy: confirm
Agent surface
Any MCP/CLI agent
Kind
Skill
Install
Single
Trust
Trust: Established
Entrypoint
OSRM Overview
Review-first command
npx -y tokrepo@latest install 30d7ed39-767a-11f1-9bc6-00163e2b0d79 --target codex

Dry-run first, confirm the writes, then run this command.

Introduction

OSRM (Open Source Routing Machine) is a C++ routing engine that computes fastest paths on road networks derived from OpenStreetMap. It preprocesses map data into a compact graph representation, enabling sub-second responses for route, table, match, trip, and nearest queries.

What OSRM Does

  • Computes point-to-point routes with turn-by-turn instructions
  • Generates distance and duration matrices for many-to-many queries
  • Matches GPS traces to road segments via map matching
  • Solves traveling salesman approximations with the trip service
  • Finds nearest road segments for snapping coordinates to the network

Architecture Overview

OSRM uses a multi-level Dijkstra (MLD) or contraction hierarchies (CH) algorithm. During preprocessing, the road graph is extracted from OSM PBF files using Lua profiles that define vehicle-specific speeds and restrictions. The preprocessed data is loaded into memory by the HTTP server (osrm-routed), which handles concurrent requests via a thread pool and responds with JSON including geometry, duration, and step-by-step instructions.

Self-Hosting & Configuration

  • Run with Docker using the official ghcr.io/project-osrm/osrm-backend image
  • Download region-specific OSM extracts from Geofabrik or planet.openstreetmap.org
  • Customize routing behavior by editing Lua profiles for car, bicycle, or foot
  • Use MLD algorithm for faster preprocessing and comparable query speed to CH
  • Deploy behind a reverse proxy with caching for production workloads

Key Features

  • Sub-second response times even for cross-country routes on a single machine
  • HTTP API compatible with the OSRM API v1 specification used by many frontends
  • Lua-scripted profiles allow customizing speeds, turn penalties, and access restrictions
  • Supports alternative routes, waypoints, and route annotations (speed, duration per segment)
  • Compact preprocessed data fits continental datasets in moderate RAM

Comparison with Similar Tools

  • GraphHopper — Java-based, supports more profiles out of the box, easier customization
  • Valhalla — multi-modal routing with transit support, dynamic costing, tiled data
  • Google Directions API — cloud service, broader data coverage, usage-based pricing
  • pgRouting — SQL-based routing inside PostgreSQL, slower but tightly integrated with spatial queries

FAQ

Q: How much RAM does OSRM need? A: A planet-wide dataset requires roughly 64 GB RAM. Country-level extracts typically need 2-8 GB.

Q: Can OSRM handle real-time traffic? A: OSRM uses static edge weights. For live traffic, you need to reprocess data or use tools that support dynamic costing.

Q: Does it support public transit routing? A: No. OSRM focuses on road-network routing. For multi-modal transit, consider Valhalla or OpenTripPlanner.

Q: How often should I update the map data? A: Reprocess from a fresh OSM extract weekly or monthly depending on how current your routes need to be.

Sources

Discussion

Sign in to join the discussion.
No comments yet. Be the first to share your thoughts.

Related Assets