Real-World Buildings Without Breaking the Bank
How we serve millions of real-world places from compressed files on object storage, with Redis in front, instead of a database or per-request API calls.

November 2026 update: the catalogue now has 23 building types in eight families, and each place keeps one of the six original types. The places bucket is now private and read with signed requests, and cached cells now live for an hour instead of ten minutes.
Why Real-World Buildings Matter
One of the things that makes Retropolis special is that the game map is the real world. When you walk down your street, you see actual restaurants, shops, and landmarks — and you can purchase them as in-game buildings that generate revenue for you.
This isn't a gimmick. It's the core engagement loop. When a coffee shop you pass every morning becomes your building in the game, it creates a connection that no procedurally generated map can replicate. Players check their buildings while commuting, compete for ownership of local landmarks, and discover places in their own city they didn't know existed.
Every building in Retropolis has a type — food, shop, bar, office, culture, or station — derived from the place's real-world category. This means the real-world character of a neighborhood directly shapes the in-game map around it.
But here's the thing: to make this work, we need access to millions of real-world places, globally, with categories, coordinates, and names. And that's where it gets expensive.
The Problem: Place Data at Scale
Location-based games need a source of truth for what exists in the real world. Ours is Foursquare Open Source Places, the open dataset of places that Foursquare publishes.
The usual alternative, calling a places API every time a player opens the map, means paying per request, and the number of requests grows with every player and every map open.
An open dataset avoids that, but it has to live somewhere. The obvious home is a database. Yet this data doesn't change during gameplay: a restaurant doesn't move. A database would mean paying for an always-on server, backups and migrations around what is essentially a read-only lookup table.
The Approach: H3 + Object Storage
We index places with H3, Uber's hexagonal spatial indexing system, and keep them out of the database entirely.
The key insight: if the data is static and read-heavy, it belongs on object storage, not in a database.
Here's the architecture:
Step 1: Process and Partition
We run a pipeline that reads the Foursquare dataset with DuckDB, filters and categorizes each place into our six building types, computes its H3 cell index, and groups places by their H3 parent cell at a coarser resolution (resolution 4). Each group gets compressed into a single gzipped JSON file.
For scale: our September 2026 export kept 26.5 million of the dataset's 109 million places, in 43,770 files totalling about 1.6 GB.
Step 2: Store on R2
Those files sit on Cloudflare R2 (S3-compatible object storage). When a player opens their map, the server computes which H3 cells are visible, fetches the corresponding files, and caches them in Redis.
The game server is the only reader: players never download these files themselves. R2 charges no egress fees, and there are no connection pools or query plans to tune.
Step 3: Cache Aggressively
Once a file is loaded from R2, its places are cached in Redis, split by the finer cells the map asks for. Subsequent requests for the same area are served from memory until the cache expires.
The Tradeoffs
No architecture is perfect. Here's what we gained and what we gave up:
What we gained:
- Cost: Storing files is cheap, and R2 egress is free.
- Latency: Cached cells are served from Redis without touching R2.
- Operational simplicity: No database to manage for places, no replicas, no migrations, no connection pooling
- Updates: A new dataset is a new export uploaded next to the old one; the server is then pointed at it. No migration.
What we gave up:
- No ad-hoc queries: We can't run
SELECT * FROM places WHERE name LIKE '%pizza%'anymore. The data is pre-partitioned by location, period. - Fixed spatial resolution: The H3 cell size is baked into the file structure. Changing it means regenerating everything.
- Cold starts: The first request for a rarely-visited area has to download and decompress a whole resolution-4 file. That can take seconds, which is why we later raised the cache lifetime from ten minutes to an hour.
For a game where place lookups are "what's near this coordinate," these tradeoffs are in our favor.
Built Places: Where Postgres Still Shines
Static place data lives on R2, but once a player purchases a building, that place goes into a PostgreSQL table of built places, indexed by the same H3 cells: which place is built, and by whom. This is dynamic data, queried by location, and a relational database is the right tool for it. The building's own state, such as its level, lives with the player's data in Firestore.
The separation is clean: R2 for "what exists in the world," Postgres for "what players have done with it." The server merges both views when responding to map requests, filtering out already-built locations from the static pool.
What's Next
We're continuing to refine the pipeline — better category mapping, smarter filtering, and potentially integrating additional data sources. The beauty of this architecture is that the serving layer doesn't care what generates the files. As long as the format stays the same, we can swap out or combine data sources without touching the game server.
If you're building a location-based game and wrestling with place data costs, the takeaway is simple: treat static geodata as files, not rows. Your database will thank you.