r/selfhosted • • 8d ago

Product Announcement Self-host planet scale geocoding with 630M+ records in a <30 GB memory-mapped index

Geocoding converts street addresses into geographic coordinates, making it possible to use them in applications like delivery routing, store locators, and mapping services.

If you're doing this at scale, API costs add up quickly. One team was quoted $14,000 by Google to geocode 2.8 million addresses.

I figured there should be a way to run this yourself but projects like Pelias, an open-source geocoder, estimates about 16 hours on a 36-core machine for a full planet build. The resulting index takes up about 450 GB in Elasticsearch

I’ve been working on OpenGeocode, a self-hosted geocoder built on OpenStreetMap and OpenAddresses. The global search index holds 630M+ records in a single file under 30 GB. To serve it, you run one binary or mount the file in Docker. There’s no separate database to maintain, and updating the index is a file swap.

You can also build an index for just the area you need. Planet index builds in about 5 hours on a 9 GB memory budget. The Netherlands index built in under two minutes.

The TypeScript SDK has client adapters for Google, HERE, Mapbox, and Precisely. Supported endpoints return the vendor’s response format using data from your own Pack. Supported APIs and response examples

I've also made the prebuilt USA index available for free. No build required. Download the USA Pack

Try the live API

Install OpenGeocode v1.0.0

GitHub

Not done yet. There's still plenty more to get right.

68 Upvotes

17 comments sorted by

•

u/asimovs-auditor 8d ago edited 8d ago

Expand the replies to this comment to learn how AI was used in this post/project.

→ More replies (1)

3

u/mattsteg43 8d ago • Bravo

Why use this instead of something established like photon?  Feels kinda astroturfed and oversold

6

u/Alternative-Bike8120 8d ago

Because it's much easier to self-host as it runs on a 30 GB mmapped file. To put that into perspective, hosting Photon on Hetzner Cloud at the recommended 64 GB of RAM would cost €275.99/month for a planet-wide db. I can run OG for the price of a coffee per month on a CX23 at €5.49/month or deploy it on a scale-to-zero platform. Again, it depends on what you consider overselling, but there are more head-to-head benchmarks in the repo.

4

u/mattsteg43 8d ago • Bravo

photron isn't nearly that difficult to host and https://github.com/rtuszik/photon-docker is nowhere near as resource intensive as you suggest and under light load uses like 600MB of RAM.

4

u/Alternative-Bike8120 8d ago

If you’re serving the full planet at 600 MB, I’d be interested in what request rate and latency you’re seeing. I couldn’t find that number in the repo you linked.

0

u/mattsteg43 8d ago

It's at effectively zero load - it's just spun up for my personal use.

Performance is "it works, so I haven't tested"

Ease of use is "docker compose up and wait for initial data download"

0

u/DarkAbhi 7d ago

Well that's not how everyone's using it

5

u/mattsteg43 7d ago

sir, this is r/selfhosted.

I guarantee more of this crowd is hosting for like 1-10 users than spending $14000 on geocoding API calls.

And of those with more demanding requirements...are they really well-served by what's effectively a solo project with like 1.5 months of active history and another little burst earlier this year?

13

u/buttplugs4life4me 8d ago

Seems pretty cool. Not really commenting on AI, but I'm hoping you use it responsibly. Addresses, Geocoding and so on are all areas that have been very entrenched into cloud APIs and desperately need some open alternatives that are more lightweight and easier to host

3

u/SMELLYCHEESE8 8d ago

Back in the early days of Esri credits one of my coworkers blew through a large consulting firm’s credits for the entire year with a sloppy geocode request, lol. Jack is so greedy

12

u/FckngModest 8d ago

Dawarich's author made Atlas a while ago for self-hosting as well, btw. https://github.com/dawarich-app/atlas

And he even has a way-cheaper-than-google option as a paid hosted service as well if you don't want to host yourself: https://chibigeo.com/

1

u/[deleted] 7d ago

[removed] — view removed comment

2

u/Alternative-Bike8120 7d ago

For parsing I use a semi-Markov CRF (same family as libpostal), trained at build time on a sample of the addresses you care about in your pack. Before parsing, I normalize Unicode, lowercase the text, and fold latin characters. I keep punctuation as a clue for the parser.

I use OpenCage’s oss address formatting templates to make training examples, then mix in things like missing fields, abbreviations, and typos. The parser uses word lists and the pack’s FST dictionaries to recognize abbreviations and catch some typos. Tantivy handles some fuzzy matching during search too. I think I can do better with parsing, and I’ve been running more experiments on messy inputs.