3liz / lizmap-docker-compose

Run Lizmap stack with docker-compose
31 stars 42 forks source link

Where is located cache directory ? #12

Closed Doctor-Who closed 3 years ago

Doctor-Who commented 3 years ago

A good question this time (I hope so) I cannot understand / find by myself where is store tile cache with this configuration.

In a standalone non docker installation, admin menu show what cache directory is use (or redis database) With Docker Compose I really don't know ? In the Redis container ?

Good to know to avoid lost all tile cache when restarting docker-compose ^^

Thanks you.

dmarteau commented 3 years ago

The docker compose use a Redis cache.

BUT: if you want to persits your cache you need to mount the redis db outside the container or in a named volume.

You may also modify the LIZMAP_CACHESTORAGETYPE to whatever storage type you want (You should refer to the Lizmap documentation about possible values)

refs:

Doctor-Who commented 3 years ago

Thank you David

A la prochaine ;)

Doctor-Who commented 3 years ago

I'm reopening the issue because something went wrong and I cannot explain. I'm modify docker compose to set redis persistant

  redis:
    image: redis:5
    command: ["redis-server", "--appendonly", "yes"]
    volumes:
      - ./lizmap/redis-data/:/data
    restart: unless-stopped

When I'm launching script.php seeding for tile generation, file named appendonly.aof is growing but RAM too. After one night seeding, my file is only 2.7 G but RAM (187 G) and swap (150 G) are full. I've got error following in the container lizmap_lizmap : Error for tile: 75_nouvelle_aquitaine_2020_cog / EPSG:2154 / 5 / 61 / 673 Error, tile not cached: 75_nouvelle_aquitaine_2020_cog / EPSG:2154 / 5 / 61 / 673

So I've restarted container lizmap_map (qgis server) and swap and ram get empty. I'm quite confusing of this result why the appendonly.aof is only 2.7 G and the rest seems store in RAM / SWAP ?

Thanks for your advice

dmarteau commented 3 years ago

I don't known what the script do and what is the Lizmap error about, but you must know that ther is several cache involved: the cache that may grow is may be the Qgis/Gdal cache from py-qgis-server and depends on things like: the number of projets/layer and the number of configured worker (workers are not sharing data, they are independant processes) and the maximum number of project that Qgis/py-qgis-server that each worker may cache.

Doctor-Who commented 3 years ago

Ok understanding, even if the memory cache size was fixed since QGIS server 3.12 (old discussion foss4G 2019) So I need to retry by reduce or disable the QGSRV_CACHE_SIZE: 'x' Can you tell me if 0 means no limit or disable ?

dmarteau commented 3 years ago

No, you cannot disable it or set it unlimited. It is 10 by default but if you have projects with many layers maybe should lesser that number.

Doctor-Who commented 3 years ago

Ok thanks for answer, Problem I think is that I've got a orthophotograpghy regional scale at 20 cm.

Doctor-Who commented 3 years ago

I will try to generate step step, one layer once with one scale level. A relevant features would be to force cache in the the cache file system (redis persistant or filesystem) when using php script for seeding. Otherwise it won't be suitable for production :(

dmarteau commented 3 years ago

A relevant features would be to force cache in the the cache file system (redis persistant or filesystem) when using php script for seeding.

This is a cache configuration issue, note that redis is persistent if your configuration make it so (persistent data volume, but afaik redis store all data in RAM and flush periodically to disk.

So if you have cached material that may exceed your ram you will have to change your cache strategy: use redis distributed cache or configure lizmap to use file cache storage instead of Redis.

Doctor-Who commented 3 years ago

Last feedback : I've try on several type of layers. This happen only for raster (even small ones) Cache generation with vector works and stored into Redis even with a large amount of polygon 1.5 millions but not working fine with Raster

dmarteau commented 3 years ago

Cache generation with vector works and stored into Redis even wit

Afaik the redis cache only raster rendering from lizmap (i.e getmap request), not vectorized objects so its less than probable that the issue is about raster vs vector.

Note that a cache used for caching arbitrary sized getmap request is totally inefficient as you will cache a lot of overlapping regions. Consider using a cache if your are using tile rendering.

I really think you will have better et more complete answers if you ask questions about cache directly at the Lizmap team as the cache usage is completely driven by the Lizmap service.

Doctor-Who commented 3 years ago

You're right, it's about cache generation with PHP command from Lizmap. I will open new issue on the right project. Thanks for your help.