Part 7: Distance Matrix Computation & Dynamic Geo-Routing

← Previous Chapter: Part 6 — Building a Mini Engine in Go | Series Hub | Next Chapter: Part 8 — Intelligent Order Release → Answer-first: To optimize Vehicle Routing Problem (VRP) order allocation, self-hosting OSRM or GraphHopper eliminates costly commercial APIs like Google Maps. Combining Haversine pre-filtering with Uber H3 Resolution-9 hexagonal Redis caching achieves a 95% cache hit rate, cuts matrix computation costs by 99.7%, and guarantees sub-3ms routing lookups across millions of urban delivery coordinates. ...

August 23, 2026 · 13 min · Lê Tuấn Anh

GPS Map Matching for Urban Canyon Noise: HMM & Kafka

GPS Map Matching for Urban Canyon Noise: HMM & Kafka Answer-first: Raw GPS data from IoT devices in dense urban environments suffers severe degradation due to the Urban Canyon effect. Traditional filters like Kalman fail because they lack spatial awareness (topology). The standard architectural solution is a Streaming Pipeline (using Kafka for backpressure) paired with a Map Matching Engine (OSRM or GraphHopper) powered by a Hidden Markov Model (HMM) to snap coordinates back to the road network at sub-50ms latency. ...

August 12, 2026 · 8 min · Tuan Anh

OSRM vs GraphHopper: Routing Engine Benchmarks & RAM

OSRM vs GraphHopper: Routing Engine Benchmarks & RAM Answer-first: Comparing OSRM and GraphHopper shows OSRM excelling in raw speed (<2ms single queries, <20ms 100x100 matrix) via C++ Contraction Hierarchies and Linux POSIX shared memory (mmap), while GraphHopper provides flexible Java-based runtime Custom Models, turn restrictions, and multi-profile vehicle fleets. For static ride-hailing matrices, choose OSRM; for heterogeneous delivery fleets with weight/height limits, choose GraphHopper. Introduction: When Do You Outgrow Cloud Route APIs? Building early-stage logistics applications with cloud routing APIs provides immediate reliability, accurate ETAs, and zero infrastructure maintenance. However, when daily traffic exceeds 100,000 requests or requires massive distance matrices for vehicle route optimization, proprietary API costs explode while rigid routing profiles prevent injecting custom fleet constraints. ...

July 17, 2026 · 11 min · Lê Tuấn Anh

GraphHopper Distance Matrix: API & OSM Hosting Guide

GraphHopper Distance Matrix: API & OSM Hosting Guide Answer-first: GraphHopper distance matrix is a high-performance open-source routing engine endpoint that calculates travel times and road distances for N×M origin-destination coordinate pairs using OpenStreetMap data. By utilizing Contraction Hierarchies and memory-mapped graphs, self-hosted GraphHopper evaluates a 100×100 matrix in under 52ms, providing 99.7% cost savings over commercial APIs with runtime vehicle customization. How to Call the GraphHopper Matrix API (/matrix Endpoint) Running GraphHopper distance matrix in production requires configuring Docker deployment, the /matrix API endpoint, Custom Models for vehicle-specific routing (truck/motorcycle), H3-based Redis caching, and evaluating performance tradeoffs against OSRM, Valhalla, and Google Maps (for an in-depth analysis of routing engine selection, see our OSRM vs GraphHopper Architecture Comparison). ...

June 11, 2026 · 17 min · Lê Tuấn Anh

OSRM Shared Memory on Kubernetes: Zero-Downtime Updates

OSRM Shared Memory on Kubernetes: Live Traffic Updates with Zero-Downtime Answer-first: Operating OSRM on Kubernetes with live traffic updates uses POSIX shared memory (/dev/shm), atomic memory pointer swapping via osrm-datastore, and Multi-Level Dijkstra (MLD) cell customization without restarting routing pods. Sharing a single 15GB graph across 10+ worker pods cuts node RAM usage by 85%+ while delivering sub-2ms P99 matrix latencies and zero-downtime speed updates. The Challenge of Operating Large-Scale OSRM on Kubernetes Normally, the osrm-routed process loads the entire binary map file directly into its Heap Memory. For massive files weighing tens of gigabytes, a single Kubernetes Pod can take anywhere from 5 to 10 minutes to finish loading before it becomes healthy and ready to serve traffic. This creates two fatal operational issues: ...

May 15, 2026 · 12 min · Lê Tuấn Anh