MCPSERV.CLUB
Open Source Routing Machine

Open Source Routing Machine

Self-Hosted

Fast C++ engine for routing on OpenStreetMap data

Active(88)
7.2kstars
0views
Updated 4 days ago

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, and tile endpoints 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++ libosrm library 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 in docs/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-frontend provides a Mapbox GL JS interface, but any JavaScript mapping library can consume the API. Text instructions are generated by osrm-text-instructions.

Developer Experience

  • Documentation: Comprehensive docs are hosted at project-osrm.org and include API reference, profile authoring guides, and pre‑processing tutorials. The source repo contains a detailed docs/ 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 libosrm in 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

Weekly Views

Loading...
Support Us
Most Popular

Infrastructure Supporter

$5/month

Keep our servers running and help us maintain the best directory for developers

Repository Health

Loading health data...

Information

Category
other
License
BSD-2-CLAUSE
Stars
7.2k
Technical Specs
Pricing
Open Source
Database
None
Docker
Official
Supported OS
LinuxDocker
Author
Project-OSRM
Project-OSRM
Last Updated
4 days ago