Rising costs from pay-per-load commercial mapping APIs are pushing some developers toward self-hosting. A technical post recently shared within the community details how to serve custom map tiles from a plain S3-compatible storage bucket, with no dedicated tile server, using the PMTiles format from the Protomaps project.
The problem: paying per map load
Commercial mapping APIs such as Mapbox typically charge once a free tier is exceeded, around five dollars per thousand map loads. For a consumer project hit by a sudden traffic spike, the bill can climb within hours with no cost guardrail kicking in in time.
PMTiles: a single file served through byte ranges
The PMTiles format packs an entire tile set into a single file. A visitor’s browser only downloads the bytes matching the displayed area and zoom level, using HTTP range (Range) requests. No application server is needed: plain static storage able to answer that kind of request is enough, provided the CDN sitting in front of it caches those responses.
| Item | Commercial mapping API | Self-hosted PMTiles (S3-compatible CDN) |
|---|---|---|
| Pricing model | Per map load, beyond a free tier | By storage and bandwidth consumed |
| Full world map (~139 GB) | Not applicable (usage-based pricing) | Roughly $5/month in storage with replication |
| Loading a European city | Counted as one billable load | Roughly 5 MB transferred, about $0.00005 |
| Server component required | None, handled by the provider | None, just static storage with range-request support |
Setting it up on S3-compatible storage
The documented process relies on a command-line sync tool, similar to the ones listed in this overview of CLI tools for web development, to transfer the large file to storage, then on configuring a CDN pull zone on top:
rclone config create bunnycdn s3 \
provider=Other \
access_key_id="<zone-name>" \
secret_access_key="<storage-key>" \
endpoint="https://<primary-region>-s3.storage.bunnycdn.com"
rclone copyurl --multi-thread-chunk-size=256M \
https://build.protomaps.com/latest.pmtiles bunnycdn:maps/world.pmtilesOn the CDN side, three settings make the difference: explicitly enabling range-request caching for large objects, restricting allowed referrers so a third party cannot embed the map on their own site, and capping download speed after the first few megabytes to discourage downloading the whole file. In the browser, integration goes through the MapLibre GL library and the pmtiles package, which registers the protocol needed to read the file by ranges. The approach echoes, in its cost and responsibility trade-offs, the one detailed for fully self-hosting a WordPress site.
A 139 GB map file can cost around five dollars a month to host, against pricing that tracks traffic directly at a commercial provider.
Limits worth knowing before committing
Self-hosting shifts responsibility for data availability and freshness onto the team running it: Protomaps’ world extracts are rebuilt regularly, but applying an update means re-downloading or recomputing some or all of the file. For a project that only needs a limited geographic area, the go-pmtiles command-line tool can extract a precise bounding box and sharply cut the file size to host, which in turn simplifies later updates.
Key takeaways
PMTiles shifts the cost of an interactive map from billed loads to raw storage and bandwidth, with the server component reduced to static storage. The savings are real for high or unpredictable traffic, at the cost of greater responsibility for data freshness and fine-grained CDN configuration.
I keep seeing this same pattern on other infrastructure pieces for my independent clients: as soon as a provider charges per use for data that can be served statically, self-hosting behind a decent CDN pays off well before traffic gets massive. The switch takes a bit more upfront rigor, but it removes an unpredictable cost line from the budget of a project that cannot always absorb a billing spike. — Simon Janvier
Further reading
The full write-up, including the figures and CDN configuration, is available on its author’s blog.
