Overview
Discover what makes Open Source Routing Machine powerful
Open Source Routing Machine (OSRM) is a high‑performance routing engine written in modern C++ that ingests OpenStreetMap (OSM) data and exposes a lightweight HTTP API, a C++ library interface, and a Node.js wrapper. At its core, OSRM implements state‑of‑the‑art shortest‑path algorithms—Contraction Hierarchies (CH) and Multi‑Level Dijkstra (MLD)—to compute routes, distance matrices, and map‑matching in real time. The engine is designed for self‑hosting; Docker images are provided for rapid deployment, but the binaries can also be compiled from source and run on any Debian‑based host.
Routing Services
Customizable Profiles
Extensible API
Language
Overview
Open Source Routing Machine (OSRM) is a high‑performance routing engine written in modern C++ that ingests OpenStreetMap (OSM) data and exposes a lightweight HTTP API, a C++ library interface, and a Node.js wrapper. At its core, OSRM implements state‑of‑the‑art shortest‑path algorithms—Contraction Hierarchies (CH) and Multi‑Level Dijkstra (MLD)—to compute routes, distance matrices, and map‑matching in real time. The engine is designed for self‑hosting; Docker images are provided for rapid deployment, but the binaries can also be compiled from source and run on any Debian‑based host.
Key Features
- Routing Services:
route,nearest,table,match,trip, andtileendpoints allow developers to retrieve fastest routes, snap coordinates to the road network, generate distance/duration matrices, perform map‑matching of noisy GPS traces, solve TSP heuristics, and produce Mapbox Vector Tiles enriched with routing metadata. - Customizable Profiles: A user‑defined routing profile (written in Lua) specifies vehicle types, speed limits, turn restrictions, and penalties, enabling fine‑grained control over travel behavior for cars, bicycles, pedestrians, or any custom mode.
- Extensible API: The C++
libosrmlibrary can be embedded into other applications, while the Node.js wrapper exposes the same functionality to JavaScript developers. The HTTP API follows a REST‑like contract documented indocs/http.md, making it trivial to integrate with existing web stacks.
Technical Stack & Architecture
- Language: C++17/20 for core engine; Lua for routing profiles.
- Data Structures: Binary routing graphs serialized to disk using custom formats (e.g.,
osrm-*.osrm). Pre‑processing steps (osrm-partition,osrm-customize,osrm-contract) generate auxiliary data (hierarchy levels, contraction hierarchies) that accelerate query time. - Algorithms:
- Contraction Hierarchies (CH) – fast for large distance matrices, single‑source shortest paths.
- Multi‑Level Dijkstra (MLD) – efficient for general routing queries, scalable to continental‑sized networks.
- No External DB: All data is loaded from pre‑processed files into memory; no external database required, simplifying deployment.
Deployment & Infrastructure
OSRM is stateless once the routing data is loaded; it can be horizontally scaled by running multiple instances behind a load balancer. Docker images are lightweight (Debian base, ~200 MB) and support docker‑compose setups for the backend plus optional frontend (osrm-frontend). For high availability, developers can mount the .osrm files on a shared NFS or use container orchestration (Kubernetes) with persistent volumes. Memory consumption scales linearly with network size—typical continental datasets fit comfortably in 32–64 GB of RAM.
Integration & Extensibility
- Plugins: While OSRM itself has a limited plugin system, custom routing profiles and Lua scripts act as plug‑ins to alter behavior without modifying the core code.
- Webhooks & Callbacks: The HTTP API supports JSON payloads; developers can hook into route calculation events via middleware in their own services.
- Frontends: The open‑source
osrm-frontendprovides a Mapbox GL JS interface, but any JavaScript mapping library can consume the API. Text instructions are generated byosrm-text-instructions.
Developer Experience
- Documentation: Comprehensive docs are hosted at
project-osrm.organd include API reference, profile authoring guides, and pre‑processing tutorials. The source repo contains a detaileddocs/directory. - Community: Active Discord, IRC, and mailing list channels provide quick support. The project’s CI pipeline ensures that new commits are rigorously tested across multiple OSes.
- Licensing: BSD‑3 license grants full freedom to modify and redistribute, making OSRM attractive for commercial deployments.
Use Cases
- Fleet Management: Real‑time routing and distance matrices for delivery fleets, with custom vehicle profiles.
- Navigation Apps: Embedding
libosrmin mobile or embedded devices for offline navigation. - Geospatial Analytics: Generating origin‑destination matrices at scale for urban planning or traffic simulation.
- Custom Transport Modes: Defining unique routing logic (e.g., electric vehicle range constraints) via Lua profiles.
Advantages Over Alternatives
- Performance: CH and MLD deliver sub‑millisecond route queries on continental datasets, outperforming many commercial APIs.
- Flexibility: Full control over data ingestion and profile logic; no vendor lock‑in.
- Scalability: Stateless architecture allows easy horizontal scaling and integration with cloud-native stacks.
- Open Source & Free: BSD license removes cost barriers, while community support ensures rapid bug fixes and feature additions.
OSRM thus offers developers a robust, high‑throughput routing engine that can be tailored to any transportation scenario and deployed entirely on their own infrastructure.
Open SourceReady to get started?
Join the community and start self-hosting Open Source Routing Machine today
Related Apps in other
Immich
Self‑hosted photo and video manager
Syncthing
Peer‑to‑peer file sync, no central server
Strapi
Open-source headless CMS for modern developers
reveal.js
Create stunning web‑based presentations with HTML, CSS and JavaScript
Stirling-PDF
Local web PDF editor with split, merge, convert and more
MinIO
Fast, S3-compatible object storage for AI and analytics
Weekly Views
Repository Health
Information
Explore More Apps
Lychee
Self-hosted photo management for personal galleries
Alfresco Community Edition
Open‑source content and process management for enterprises
MyFin
Personal finance platform for budgeting and tracking

Digiview
Self-hosted digital collection organizer and viewer
Navidrome
Self‑hosted music streaming like Spotify
Runtipi
All‑in‑one self‑hosted app orchestrator