Hacker News new | ask | show | jobs
by Nnnes 16 days ago
Once you get outside Cloudflare's free tier, the Bunny setup in the original post beats it pretty quickly. Cloudflare costs $0.30 (Workers invocations) + $0.36 (R2 class B operations) per million requests. Bunny charges for bandwidth but not per request (!!), so assuming an average of 1kB/request (map vector tiles should be a bit less than this in my experience) that's $0.005-$0.06 per million depending on which region and tier you're serving from.

The real "too good to be true" might be GitHub Actions building a 100GB+ PMTiles file for free

1 comments

I think PM tiles are quite a bit larger. Just loading at a low zoom level a view of the world triggers requests of ca. 500kB on my site, though that might also overscan a bit or include the file header. From my calculations, for Bunny to be cheaper the avg request should be at most 660kB at $0.01/GB which should probably hold true (I think just the worker invocations alone are already equivalent to 300kB of traffic on Bunny)
Huh yeah you're right, I was off by about 100 orders of magnitude. pmtiles.io shows tile sizes with "Show tile bounds" checked and they're mostly in the 30-100 kB range.

Bunny's volume tier costs $5/TB served, i.e. $1 gets you 2~6.7 million tiles served, probably closer to 3.

But Cloudflare also allows public R2 buckets so we could potentially ignore the Workers cost, i.e. $1 gets you 2.8 million tiles served. I think caching just works in front of R2? So you get significant gains if your visitors are mostly looking at the same areas and not zooming in all the way to their house every time.

So they come out pretty evenly or with Cloudflare a bit on top depending on the scenario. Bunny does has the advantage of easy data replication across regions (I don't know of a good way to achieve this with R2, although D1 has some kind of replication feature in beta).

Both are still far, far cheaper than almost any vector tile subscription I've come across. And, of course, more expensive than self-hosting (at least at the hobbyist level).

When you have a CDN in front of object storage it's not so easy to compare as the origin requests go out in chunks. For caching in front of R2, you need the worker, as Cloudflare only permits file sizes of up to 512MB regardless of the range requested. And then there's the latency difference of working directly with R2 (Protomaps calls out latency up to 500ms and on a previous blog post I measured 300-600ms on HEAD requests against R2[0])

[0]: https://bruceroettgers.eu/blog/benchmarking-r2-head-requests...