weserv / images

Source code of wsrv.nl (formerly images.weserv.nl), to be used on your own server(s).
https://wsrv.nl/
BSD 3-Clause "New" or "Revised" License
1.97k stars 193 forks source link

Azure - Docker - No space left on device #382

Closed tompodsiadlo closed 12 months ago

tompodsiadlo commented 1 year ago

Hello, I am running your docker image on Azure container app and I am getting No disc space left errors and request are starting to fail. So I was wondering how do you implement server side caching, is url key to it or is it combination of url and request? Ive read your docs and check code but couldnt find details if you cache every 'source image' or every resized/cropped image. Sorry to bother you.

andrieslouw commented 1 year ago

Every request URL is cached, so every resized/cropped image. We utilize NGINX proxy_cache to do this, but it should be in RAM (/dev/shm/) by default.

Could it possibly be logfiles that cause the disk to fill up? Did you investigate which paths where taking up the most space?

@kleisauke : Is there disk caching in the Docker?

tompodsiadlo commented 1 year ago

Errors from logs 50978 pwritev() "/dev/shm/proxy_cache/3/c4/54e6b431c8a6682c2f8ef8df24022c43.0000010488" failed (28: No space left on device) while reading upstream, it is very weird because we resize every img so all images should be rather small

andrieslouw commented 1 year ago

How much RAM do you have? Because /dev/shm should be RAM. You can try to play with the max value in the nginx config: https://github.com/weserv/images/blob/ca63088b93de7501eeb5d9f298380e36162b566f/ngx_conf/imagesweserv.conf#L1-L3

tompodsiadlo commented 1 year ago

So my container app had 1core 2gb of RAM now i scaled it to 2cores 4gb but if im reading the config correctly max size is 250mb, right? So changes to my container app in terms of ram are not rly affecting cache size? I have cdn over img server so images should be cached there but still I was running out of disk space and new images were starting to fail

kleisauke commented 1 year ago

I suspect the shared memory size limit of the Docker containers was not increased, which is set to 64MB by default. The --shm-size flag can be used to increase this limit, but I'm uncertain if this option is available in Azure.

You can also disable any caching by using the imagesweserv-no-cache.conf config. For example:

FROM ghcr.io/weserv/images:5.x

RUN cp ngx_conf/imagesweserv-no-cache.conf /etc/nginx/imagesweserv.conf
kleisauke commented 12 months ago

@tompodsiadlo Were you able to make any progress with this?

tompodsiadlo commented 12 months ago

Hello, we ended up using no cache config and problem was solved. Since we are using cdn over img server we could go that direction.