geospatial-jeff / aiocogeo

Asynchronous cogeotiff reader
MIT License
73 stars 10 forks source link

Cache only COG header #82

Closed dmahr1 closed 3 years ago

dmahr1 commented 4 years ago

https://cogeotiff.slack.com/archives/C01DE57GLHE/p1603130953009500

Summary

Consider a case where N unique tile requests are made to a single COG. Despite the ENABLE_CACHE environment variable being enabled, all requests would be cache misses. Thus at least 2 * N range requests would need to be made to the COG. But if the COG header were cached separately, then only 1 + N range requests would need to be made.

Details

I plan to incorporate aiocogeo within a traditional tile server middleware that handles regular z/x/y.png requests. These currently read PNG tiles that are stored as a tile pyramid in bucket storage. This dated architecture is space inefficient but very performant. I'm hoping to achieve the space savings of COGs (via YCbCr JPEG compression + GDAL mask bands) without a meaningful increase in latency. One way to eliminate that latency is by caching the header in redis or another fast cache available to many servers. For example:

The two italicized operations for the first request are not necessary for the second request.

geospatial-jeff commented 3 years ago

This was implemented in https://github.com/geospatial-jeff/aiocogeo/pull/90, will be included in the next release!

dmahr1 commented 3 years ago

Amazing! You're a hero, @geospatial-jeff. I was planning to play around with this over the holidays but you beat me to it!