NASA-IMPACT / NASA-IMPACT/veda-odd

Warped chunk caching

Open
#427 2 comments 5 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
No language data
Stars
5
Forks
0
Avg merge
4d 19h
Merged PRs (30d)
3

Description

We recently had to give some presentations to members of the GIBs and EGIS teams talking about edge caching for improving the performance and scalability of some our tiling services. Two main points we noted are that caching dynamic, mosaic tiles is highly inefficient for 2 reasons

  • The very large numbers of tile permutations based on query, band ordering and colormap application.
  • The difficulty of cache invalidation when upstream granules are added or altered.

You can read more detail about these issues in https://github.com/developmentseed/chunk_caching_presentation.

In discussions about caching for titiler-cmr @hrodmn had proposed the idea of data layer caches using serialized numpy arrays to address the tile permutation issue. The warped chunk cache is the natural Zarrified extension of this concept.

Let's use a collection like HLS as an example. Granules use a variety of UTM CRSs so for almost all visualization use cases (and analysis use cases which cross UTM zones) the source chunks will need to be warped to a CRS. Currently when we dynamically tile data we pay this warping cost for every request. Instead, we want the first user to access a chunk to pay the warping penalty but save the warped result so that subsequent requesters don't need to.

Image

We start with a chunk cache Zarr array that uses the target CRS (web mercator), covers the full extent of the collection and uses a smaller reasonably aggregated time dimension (which we can incrementally extend going forward). This array is initialized with null values. When a tiling request fetches a chunk, and the chunk is null it attempts to use an index (zarr-datafusion-search, CMR, STAC) to locate the appropriate source chunks. It then applies the warping operation and writes the chunk as a native chunk to the chunk cache array.

In this way, we incrementally build a set of warped, native chunks based on request traffic. This same concept can also be applied to building multi-resolution pyramids. Rather than exhaustively pre-generating pyramids for data which might not ever be accessed, we can have pyramid chunks calculated on demand. Obviously there are scaling and latency limitations for this approach and we will likely still need to pre-generate pyramids that require many input source chunks for each target chunk.

From a cache invalidation perspective, if we have virtual chunk representations of all our source data it should be relatively simple to invert the process we use for looking up source chunks. When a new virtual chunk is created or an existing one is updated it broadcasts a notification and the warped chunk cache writer can respond by updating the warped chunk cache.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue names no repository files, tests, or entry points. Start by reviewing the linked chunk-caching presentation and locating the existing tiling, Zarr, and source-chunk lookup code. Done would require an agreed design and an implemented warped chunk cache with cache population, invalidation, and scaling behavior defined.

Written by the indexing model from the issue text.

Assessment

Tech stack
numpy
Domain
backend-api-design, data, performance
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.