Executive Summary — The Big Picture of Geospatial & Routing Architecture

The Engineering Challenge Building a modern logistics platform (like food delivery, ride-hailing, or fleet management) requires computing distances and Estimated Times of Arrival (ETA) at an immense scale. The $N^2$ Problem: If you have 1,000 drivers and 1,000 orders, calculating the distance between every possible combination requires 1,000,000 individual route calculations. Speed: These calculations must happen in real-time (under 50ms) to ensure seamless user experiences and prevent dispatching algorithms from timing out. Accuracy: The system must account for real-world constraints such as one-way streets, “no left turn” rules, and dynamic traffic congestion. Standard point-to-point APIs (like basic Google Maps API calls) are too slow and too expensive for massive Distance Matrix generation. You need an internal, highly optimized Routing Engine. ...

June 14, 2026 · 3 min · Lê Tuấn Anh

Part 8: Zero-Downtime Map Updates & Multi-Region Kubernetes

Writing a fast algorithm is only half the battle. The true test of a Principal Engineer is deploying a massive, stateful Routing Engine to the Cloud without causing a single second of downtime during map updates or infrastructure failures. Answer-first: You cannot treat Graphhopper like a stateless web server. Updating the OpenStreetMap data takes 30 minutes of heavy computation. You MUST decouple the map build process using Kubernetes Jobs, inject the pre-computed 50GB cache via initContainers, and switch traffic instantly using Blue-Green Deployments. ...

June 15, 2026 · 5 min · Lê Tuấn Anh

Part 4: Golang API & Microservices Integration (Kratos & Dapr)

Building a simple API that calls Graphhopper via http.Get is easy. Building a Principal-level API Gateway that survives 10,000 concurrent riders requesting routes without crashing is a masterclass in Distributed Systems. Answer-first: Graphhopper is a heavily CPU-bound downstream service. If your Golang API blindly accepts traffic and forwards it, a slight slowdown in Graphhopper will cause your Goroutines to pile up, exhausting your server’s RAM and triggering a cascading failure. You must implement a “Defense in Depth” strategy using Concurrency Bounding, Circuit Breakers, and Asynchronous Pub/Sub. ...

June 14, 2026 · 4 min · Lê Tuấn Anh

Part 2: Zero to Hero Environment Setup (Docker, OSM, Golang)

Setting up a local routing engine is notoriously difficult. Most generic tutorials offer a basic Docker command that crashes silently, leaving developers confused. In this guide, we bypass the basic “Hello World” setups. We will build a production-grade local environment integrating OpenStreetMap (OSM) data, a properly tuned Graphhopper (Java) Docker container, and a high-concurrency Golang API Gateway. 1. Downloading and Cropping Map Data Answer-first: Download raw OpenStreetMap data in .osm.pbf format from the Geofabrik server. To save gigabytes of RAM during local development, use osmium extract to crop the massive country-level map down to a single city bounding box. ...

June 14, 2026 · 5 min · Lê Tuấn Anh

Part 1: Core Algorithms (A*, Dijkstra) Visualized - Routing Architecture Masterclass

When building a high-scale logistics or delivery system, generic algorithm tutorials often lead developers astray. They tell you that A* is universally better than Dijkstra. However, in the real world of Routing Engines and Distance Matrices, the truth is much more complex. In this first part of our masterclass, we will move beyond academic theory. We will visualize the exact lifecycle of a routing request—from snapping a GPS coordinate to the road, to bypassing traffic, and finally calculating routes in milliseconds using Contraction Hierarchies. ...

June 14, 2026 · 6 min · Lê Tuấn Anh

GraphHopper Distance Matrix: Self-Host an Open-Source Routing Engine for Production

What Is the GraphHopper Distance Matrix? Answer-first: GraphHopper distance matrix is the /matrix API of the open-source GraphHopper routing engine. It accepts N points and returns an N×N matrix of travel durations (seconds) and distances (meters) based on real road networks from OpenStreetMap — completely free when self-hosted. For 100 delivery stops, it computes 10,000 pairs in under 50ms on a standard VPS. This guide covers everything you need to run GraphHopper distance matrix in production: Docker setup, the /matrix API, Custom Models for truck/motorcycle routing, H3-based Redis caching, and an honest comparison with OSRM, Valhalla, and Google Maps. ...

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

GraphHopper vs CARTO: Order Fulfillment Routing Engine

Answer-first: A comparison between the GraphHopper Distance Matrix API and CARTO Spatial Analytics. A guide to building an order fulfillment routing engine (VRP). In last-mile delivery and logistics, calculating a route is not just about finding the shortest path from point A to point B. When a system needs to coordinate thousands of drivers and orders simultaneously, computational costs can explode exponentially. This article will compare two popular approaches: utilizing GraphHopper for lightning-fast GraphHopper distance matrix calculation, and leveraging the CARTO Spatial Platform (focused on spatial analysis in Cloud Data Warehouses). We will also explore how to integrate this routing data into Real-time Surge Pricing Calculation to optimize operational costs. For routing within geospatial indexing systems (H3 hexagons, Redis GEO), see Part 2 — Geospatial Indexing: H3, S2 & Redis GEO. ...

June 1, 2026 · 7 min · Lê Tuấn Anh

Self-Hosting GraphHopper on Kubernetes with OSM Data

Answer-first: Step-by-step guide to deploying GraphHopper on Kubernetes with OpenStreetMap data: Docker image, PVC for OSM PBF files, RAM tuning, and health probes. GraphHopper is arguably the most capable open-source routing engine available — it supports Contraction Hierarchies (CH) for sub-millisecond route queries, custom vehicle profiles, turn restrictions, and the full OpenStreetMap road network. The problem most teams encounter is not the algorithm; it is the operational challenge of running it in Kubernetes: loading a large OSM PBF file, sizing JVM memory correctly, handling the long CH pre-processing startup time, and updating map data without downtime. ...

June 1, 2026 · 10 min · Lê Tuấn Anh