go-spatial / tegola

Tegola is a Mapbox Vector Tile server written in Go
http://tegola.io/
MIT License
1.28k stars 194 forks source link

S3 backend - redirect to storage on cache hit #746

Closed johngian closed 2 years ago

johngian commented 3 years ago

From what I understand from the codebase, currently, the supported request/response flow for for the s3 caching backend is:

  1. GET request to tile endpoint
  2. Handle GET
  3. Check if cache key (object path) is available in the bucket
  4. Fetch value (tile) from S3 if available else generate tile on the fly and cache it
  5. Return an HTTP response with the cached content

I think it would be a useful feature for some deployment scenarios to optionally support returning an HTTP redirect to S3 (or potentially a CDN in front of S3 or any other compatible API) instead of increasing the load and latency on the server side to fetch the s3 cached results and respond.

ARolek commented 3 years ago

@johngian I have worked on an architecture that's similar to what you're describing. I put together a post on it here though much of the post is about using serverless tech. The final architecture is kind of the inverse of what you're proposing. Here's the request flow:

0_R9PEGlaQt35Av4V8

Essentially you have a CDN point to an S3 bucket, if the S3 bucket produces a miss, then the request is redirected to the tegola endpoint which proceeds as normal.

Do you think something like this would work for you?

johngian commented 3 years ago

I have to check our caching layers and how this would be implemented in our deployment scenario. Thanks @ARolek for the information.

ARolek commented 2 years ago

@johngian I'm going to close this now, but feel free to re-open if you need additional help on this issue.