Skip to content

File Cache

James Fantin-Hardesty edited this page Oct 17, 2023 · 2 revisions

Cloudfuse File Cache

About

Cloudfuse File Cache is a feature which helps improve future accesses to files by caching reads and writes to a local cache. It is useful in write heavy scenarios and when reading files that are small enough to fit into the local cache.

Enable File Cache

To enable file_cache, first specify file_cache under the components sequence between libfuse and attr_cache. Note 'stream', block_cache, and 'file_cache' currently can not co-exist.

components:
  - libfuse
  - file_cache
  - attr_cache
  - azstorage

or

components:
  - libfuse
  - file_cache
  - attr_cache
  - s3storage

The different configuration options for file_cache are,

  • path: Path to local disk cache
  • policy: lru|lfu Eviction policy to be engaged for cache eviction. lru = least recently used file to be deleted, lfu = least frequently used file to be deleted. Default - lru.
  • timeout-sec: Default cache eviction timeout (in sec). Default - 120 sec
  • max-eviction:Number of files that can be evicted at once. Default - 5000
  • max-size-mb:Maximum cache size allowed. Default - 0 (unlimited)
  • high-threshold: % Disk space consumed which triggers eviction. This parameter overrides 'timeout-sec' parameter and cached files will be removed even if they have not expired. Default - 80
  • low-threshold: % Disk space consumed which triggers eviction to stop when previously triggered by the high-threshold. Default - 60
  • create-empty-file: true|false Create an empty file on container when create call is received from kernel
  • allow-non-empty-temp: true|false Allow non empty temp directory at startup
  • cleanup-on-start: true|false Cleanup the temp directory on startup, if its not empty
  • policy-trace: true|false Generate eviction policy logs showing which files will expire soon
  • offload-io: true|false By default libfuse will service reads/writes to files for better perf. Set to true to make file-cache component service read/write calls.
  • sync-to-flush: true|false Sync call to a file will force upload of the contents to storage account
  • refresh-sec: Number of seconds after which compare lmt of file in local cache and container and refresh file if container has the latest copy

Sample Config

After adding the components, add the following section to your Cloudfuse config file. The following example enables Cloudfuse to use /home/myuser/tempcache as the local cache with a maximum size of 4096 MB of memory with a timeout of 120 seconds.

file_cache:
  path: /home/myuser/tempcache
  timeout-sec: 120
  max-size-mb: 4096