go-spatial / tegola

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

[Feature Request]: add TTL per layer #817

Closed iwpnd closed 2 years ago

iwpnd commented 2 years ago

Hey, 👋

Right now, if I understand correctly, you can set a global TTL to be applied to the cache no matter the map and no matter the layer. Every SET on the cache uses said TTL if set. Some data points update more often than others. Some not at all. Now, since it's cheap to scale Redis, it is not as cheap to scale PostGIS replicas. So when I can avoid reads on the database as often as possible I'd prefer that.

Do you think it's viable to add a optional TTL to the provider config that is used instead of the global value if set?

ARolek commented 2 years ago

@iwpnd

Do you think it's viable to add a optional TTL to the provider config that is used instead of the global value if set?

Possibly, but not with the current tile cache design. The current design will cache Tiles which are a collection of layers. If you want TTL on a per-layer basis, we would probably want to cache individual Layers and then conflate them at request time. It is possible but would be quite the rework.

An alternative approach to solving the problem with the current design is to have 2 separate map configs, one is your base map and one is a highly dynamic layer. You can then set up 2 separate TTL configs. The main downside to this is that the UI will make double the tile requests, but it is common practice to have the UI conflate multiple data sources.

iwpnd commented 2 years ago

Ah, then I misunderstood the design here. Hm, you're right that would make it all the harder to support both a global and a layer config unfortunately. Splitting the one tegola deployment in two is worth a test and might already suffice. Thank you @ARolek 🙏

ARolek commented 2 years ago

Splitting the one tegola deployment in two is worth a test and might already suffice

Just to clarify on this point, you can configure multiple maps in a single tegola config, so you don't need to run 2 instances of tegola.

iwpnd commented 2 years ago

Yes, I think I understood this correctly. Yet in order to have a separate TTL on a more static layer, I'd have to have two deployments, essentially adding a second source to the client that is cached for a longer period of time.