radical-data / queering-the-map

Queering the Map is a community-based platform where individuals anonymously pin their queer experiences and stories on a global map.
https://queeringthemap.netlify.app
11 stars 3 forks source link

Load PMTiles tiles faster #50

Open nielsbom opened 1 month ago

nielsbom commented 1 month ago

Cloudflare is serving the PMTiles tiles.

But we notice that the tiles can be slow to load.

Investigate and improve how fast those tiles are served.

nielsbom commented 1 month ago

We've configured Cloudflare to cache requests, which you can see when doing the same request twice:

time curl -I 'https://tiles.queeringthemap.com/basemap/11/1240/1031.mvt'

First time:

HTTP/2 200
date: Mon, 03 Jun 2024 19:50:04 GMT
content-type: application/x-protobuf
content-length: 4478
cache-control: max-age=86400
vary: Origin
server: cloudflare
cf-ray: 88e235b78847b930-AMS

________________________________________________________
Executed in    3.43 secs      fish           external
   usr time   17.27 millis   94.00 micros   17.17 millis
   sys time    8.09 millis  528.00 micros    7.57 millis

Second time:

HTTP/2 200
date: Mon, 03 Jun 2024 19:50:07 GMT
content-type: application/x-protobuf
content-length: 4478
cf-ray: 88e235d90dad0a6b-AMS
cf-cache-status: HIT
accept-ranges: bytes
age: 3
cache-control: max-age=86400
last-modified: Mon, 03 Jun 2024 19:50:04 GMT
vary: Origin
server: cloudflare

________________________________________________________
Executed in  125.83 millis    fish           external
   usr time   11.91 millis    0.07 millis   11.84 millis
   sys time    7.77 millis    1.30 millis    6.47 millis

The first time is quite slow: 3.43 seconds, the cached URL is only 0.125 seconds.

jokroese commented 1 month ago

Great to have caching – 0.125 seconds is flying!

jokroese commented 1 month ago

Instinctively 3.4 seconds seems slow (and, as we've discussed, feels slow too). Could you do a comparison to the PMTiles from the Protomaps organisation (e.g. https://maps.protomaps.com/) and also MapTiler? That can give us a baseline for what we can hope to aim for.

nielsbom commented 1 month ago

Agreed on the slowness.

With a lot of traffic I also think we'd be hitting the cache a lot. But that's quite handwavey.