mapcache icon indicating copy to clipboard operation
mapcache copied to clipboard

mapcache_seed creates many second level dimension transactions (no wms_querybymap)

Open djhoese opened this issue 5 years ago • 7 comments

I have a mapcache instance that is using a postgresql database on the backend for a time dimension. I also have some automated cache seeding going with mapcache_seed. While monitoring the performance of the database I noticed that with the cache seeding enabled I'm seeing 100s of database transactions, hovering around 700, coming from the seeding when I should have a theoretical maximum of 68 tilesets and 3 zoom levels. This causes a CPU load of ~15 more than the typical workload. I have the wms_querybymap option enabled for my database in the mapcache xml and it seems to be working for the regular requests, but I'm guessing this optimization isn't being used for mapcache_seed.

Could someone verify that this is true? I hope to search through some of the source code today.

djhoese avatar Jan 08 '21 14:01 djhoese

CC @jbo-ads

Related: #222 #223

djhoese avatar Jan 08 '21 14:01 djhoese

I took a quick glance at source code and verified that your observation is true. The part of code involving wms_querybymap (in file lib/tileset.c, function mapcache_tileset_get_map_tiles()) is not called by util/mapcache_seed.c, neither directly nor indirectly. It is used only by lib/core.c.

jbo-ads avatar Jan 11 '21 15:01 jbo-ads

@jbo-ads Thanks for looking into it. Any idea how much work it would be to add the functionality so mapcache_seed benefits from this? Is this something someone not familiar with the mapcache source code could figure out?

djhoese avatar Jan 11 '21 15:01 djhoese

Indeed, mapcache_seed is a part of MapCache that I am not the most familiar with. I would say around one week of work.

Anyway, I'll be glad if more people get familiar with MapCache source code!

jbo-ads avatar Jan 11 '21 16:01 jbo-ads

Right now my project that is using mapcache is not the highest priority and it seems to be working quite well without the seeding so I'm not sure when (or if) I'll get to this. One week of work is quite a bit for something like this that I don't think I can spare right now.

djhoese avatar Jan 11 '21 16:01 djhoese

I can't stop thinking of that.

wms_querybymap is focused on maps whereas mapcache_seed works with tiles. What would be a dimension query-by-map in the context of tile seeding? metatile extent or full extent of seed region?

jbo-ads avatar Jan 12 '21 12:01 jbo-ads

I likely don't have a full understanding of everything (every use case) where wms_querybymap makes sense. In my case I only have basic WMS layers that mapcache is accessing with the only extra dimension being "time". I would imagine that mapcache_seed only needs to do a dimension query for each dimension for every (tileset, grid) pair since these are the parameters that can be provided. Whatever variability is available in the dimension query (the available parameters that can be replaced) then I think one query for each would make sense.

I'm guessing the non-time dimensions are where this really becomes complex.

djhoese avatar Jan 12 '21 14:01 djhoese