protomaps / PMTiles

Cloud-optimized + compressed single-file tile archives for vector and raster maps
https://protomaps.com/docs/pmtiles/
BSD 3-Clause "New" or "Revised" License
2.11k stars 125 forks source link

Is it possible to use multiple URL for a single PMTiles source? #491

Open mabhub opened 2 weeks ago

mabhub commented 2 weeks ago

Maybe related to #16

Currently in HTTP/1.1 browsers are limiting by domain how many (6) concurrent requests can be done.

Map frameworks like MapLibre, Mapbox, Leaflet (also according tilejson-spec) allow to define multiple URL for each source. Also each (file)tiles providers usually provide multiple subdomain for the same content ([a|b|c].tile.thunderforest.com, [a|b|c].tile-cyclosm.openstreetmap.fr,…). Thus allowing to bypass browsers limitation.

Is there such a way for PMTiles protocol adapter to accept multiple URL?

bdon commented 2 weeks ago

No - that solution relies on server-side aliasing of a,b,c. Does your storage platform for the PMTiles have that feature? It doesn't seem worth it to build such a server-side feature to work around the limitations of HTTP/1.1, so if your storage platform does not support HTTP2 you can use one of these proxies that all support HTTP/2: https://docs.protomaps.com/deploy/

mabhub commented 2 weeks ago

Does your storage platform for the PMTiles have that feature?

Precisely! We already have a classic tile hosting infrastructure that handles subdomains. And for PMTiles, we simply set up a reverse proxy in front of an S3 storage.

Since most map frameworks already handle the use of multiple tile URLs for each tile source, it might seem legitimate that the PMTiles protocol provides such a feature.

Could this be a feature request?

bdon commented 2 weeks ago

Why do you prefer this solution instead of HTTP/2?

mabhub commented 1 week ago

It's not a matter of preference, but rather of keeping a functionality that is for now still available with default protocol.

If you think it shouldn't be possible, I won't insist further.

bdon commented 1 week ago

Since most map frameworks already handle the use of multiple tile URLs for each tile source

This is tied to the interpolation of {subdomain}/{z}/{x}/{y}.mvt templates though, right? Most of the developer-facing APIs here forgo the z/x/y templates for plain (non-templated) urls like https://example.com/name.pmtiles so we would need to turn such plain strings into templates as well like {subdomain}.example.com/name.pmtiles.

In order to take advantage of multiple subdomains you would then need a proxy in front of S3 storage, but if you are already using a proxy it seems like the vast majority of dynamic proxies like caddy, nginx or a zxy decoder all support HTTP/2 already.

So don't feel like this solution is general enough to be part of the JS implementation, but if other users disagree then it could be reconsidered.