lancachenet / monolithic

A monolithic lancache service capable of caching all CDNs in a single instance
https://hub.docker.com/r/lancachenet/monolithic
Other
725 stars 73 forks source link

Implement NGINX 'min_free` parameter to ensure cache drive always has free space #190

Open tpill90 opened 1 month ago

tpill90 commented 1 month ago

Overview

A fairly common issue that comes up in the support Discord relates to Lancache's cache drive running out of free space in one way or another, causing issues with the cache until some free space has been cleared. It is fairly easy accidentally have this happen via various scenarios:

  1. Misconfiguration of volume mounts for /data/cache will end up writing cache files to the OS drive, which can eventually deadlock the whole system until some space is cleared.
  2. Configuring a CACHE_DISK_SIZE that is larger than than the actual available disk space.
  3. Sharing the Lancache cache disk with other applications, where even if CACHE_DISK_SIZE is correctly configured it is still possible to have other applications writing their own data, taking up space for the cache.

With the release of NGINX 1.19.5 a new parameter min_free has been added to proxy_cache_path which ensures that the specified amount of free disk space is always available. Details from the docs :

The special “cache manager” process monitors the maximum cache size set by the max_size parameter, and the minimum amount of free space set by the min_free (1.19.1) parameter on the file system with cache. When the size is exceeded or there is not enough free space, it removes the least recently used data.

Proposal

I propose the following changes:

Testing

I've pushed up a copy of monolithic with the changes to [Dockerhub(https://hub.docker.com/repository/docker/tpill90/monolithic/tags). Use the tag tpill90/monolithic:minfree to test locally.

Pull Requests

Since this change will require updating several repos, I'm going to use this issue as a single issue to keep track of all of the related pull requests in one place. I will add the pull requests below as I get them created