Best caching strategy

Hello all,

First, rclone is an awsome tool I'm using since years now for different purpose, very stable. Now I need some guidance/advice in caching strategy.

Background

I have a 8 mechanical HDD array in a Unraid server.
I have a 2T SSD hosting docker and VM, and I was using Unraid cache system to store only new files, with a script moving to array when SSD was 90% full. SSD path is /mnt/cache
I'm not using external cloud, everything are local on the same machine .
I have 40GB memory, only about 8GB are used.

I use plex to stream to several devices on LAN (gigabit ethernet) or WAN (gigabit fiber internet), and also seed torrents with transmission.

It is on a Unraid machine, process below is handled by OS:
Data are merged from all drives to /mnt/user0/data
SSD is mounted to /mnt/cache/data
My apps access to /mnt/user/data which is a merge of SSD and Array: system pick in SSD, if file is not there it picks in Array, if duplicate it use SSD's file.

What are you trying to achieve with rclone?

I'd like to use SSD as a working drive, and HDD for long term storage/backup.
My goal is then to cache full file on the SSD (unlimited time in a FIFO manner using 1T ) so apps are only accessing the SSD. Docker or VM volumes for other apps are already on the SSD.

I need advice about the goog method/parameters to use to cache from array to SSD using rclone (or using something else, maybe rclone is not the best for this job, but that's my best bet at the moment)

Now I'm testing rclone cache or rclone local remotes associated with rclone mount with different parameters.

Either rclone mounting with local remote or rclone cached remote work perfectly and files are read/writen from/to the SSD, but I'd rather want full file and transparent caching (no wait time for plex and transmission) and it seems by listing mounting point it's not the case.

What is your rclone version (output from rclone version)

rclone v1.51.0-266-gf2b1fedc-beta

Which OS you are using and how many bits (eg Windows 7, 64 bit)

Linux 4.19.98-Unraid #1 SMP Sun Feb 2 22:45:43 GMT 2020 x86_64 AMD Ryzen 7 3700X 8-Core Processor AuthenticAMD GNU/Linux

Which cloud storage system are you using? (eg Google Drive)

None

The command you were trying to run (eg rclone copy /tmp remote:tmp)

Config:

    [data-cache]
    type = cache
    remote = local:/mnt/user0/data
    plex_url = http://192.168.1.20:32400
    plex_username = *REDACTED*
    plex_password = *REDACTED*
    chunk_size = 10M
    info_age = 2d
    chunk_total_size = 1T
    db_path = /mnt/cache/rclone/cache-backend
    chunk_path = /mnt/cache/rclone/cache-backend
    workers = 10
    chunk_no_memory = true
    writes = true
    plex_token = *REDACTED*

    [local]
    type = local

Command method1:

    mntpoint4="/mnt/cache/data"
    remoteshare4="data-cache:" #(or local: local path)

    rclone mount --max-read-ahead 1024k --uid 99 --gid 100 --allow-other --vfs-cache-mode write $remoteshare4 $mntpoint4 &

Command method 2:

    mntpoint5="/mnt/cache/data"
    remoteshare5="local:/mnt/user0/data"

    rclone mount --max-read-ahead 1024k --uid 99 --gid 100 --allow-other --vfs-cache-mode full --vfs-cache-max-age 48h --vfs-cache-max-size 1T
$remoteshare5 $mntpoint5 &

Thank you for your help and guidance :slight_smile:
Take care,
Reynald

Hello all,

So I'm progressing :slight_smile:
This is solved:

but I'd rather want full file and it seems by listing mounting point it's not the case

Solution:
For plex, I corrected my network routing and it's working really good with rclone cache
For transmission, I wrote this script to cache full file that are used by transmission.

I have a question please: is there a command line argument for rclone rc to not redownload chunks if file is already fully cached?

Actually I check size before lauching chunk fetching:

REMOTE_SIZE=$(du -s "${RC_REMOTE_LOCAL_PATH}${FILE_TO_CACHE}" | awk '{print $1}')
CACHE_DB_SIZE=$(du -s "${RC_CACHE_DB_PATH}${FILE_TO_CACHE}" | awk '{print $1}')
if [[ $REMOTE_SIZE -eq $CACHE_DB_SIZE ]]

Another question: What can I do for plex which have some waiting time when launching a play, plus one buffering wait after I guess what is the jump from first to second chunk

Thanks for reading, hopefully I'll get some hints :slight_smile:

(@Animosity022 sorry to tag, but from my search here, I guess you are good with rclone cache :wink: )

Take care,

Sounds neat, but unfortunately I do not use the cache backend nor do I think torrenting is a good use case for cloud storage based on its IO patterns.

I'd use some cheap online storage for any of that and go from there. I know people do use it as it's just not my personal use case.

The cache backend is unfortunately without a maintainer and @ncw is looking to merge the key bits into the standard VFS (default) functionality.

I'd probably just wait for him to finish that up and push it out and see what can be done there rather than go too far into the cache as I'd surmise it would eventually get removed (just my guess).

If you want to write up a How To and post something in there, that is always welcome as it can be updated as well.

Thanks for your answer!

I use it with local remote, but it shall work with remote cloud storage also, good for long term seeding.
This is awsome as a local caching solution from HDD to SDD

Thank you for the highlight about maintaining etc... I hope VFS will inherit the chunk downloading thing!

For sure I will share the whole "project" when good enough for production

I put the script on my github, here: https://github.com/R3yn4ld/scripts/blob/master/rclone-cache_torrents.sh

Basically:

See background in first post

The script needs:

  • a RPC enabled transmission installation
  • a working rclone cache mount with remote-control enabled
  • credentials for both

What the script do:

When you start it, it makes basic connexion and path checks and then retrieves the list of active torrents from transmission-rpc daemon.
(note: active-torrents are those downloading and seeding during the last minute, but also starting and stopping, that's a caveat if you start/stop a batch of torrent and launch the script in the minute)

For each file of each active torrent:

  • If the size of chunks on cache is the same as the size on local remote, it does nothing
  • else the script uses rclone remote control to ask rclone cache to fetch all the chunks (full file).

This shall be close to rclone cache behavior with plex.

The script is very usefull when, like me, you have noisy/slow mechanical HDDs for storage, and quick and quiet SDD to serve files.

My setup
Rclone Config:

[data-cache]
type = cache
remote = local:/mnt/user0/data
plex_url = http://192.168.1.20:32400
plex_username = *REDACTED*
plex_password = *REDACTED*
chunk_size = 10M
info_age = 2d
chunk_total_size = 1T
db_path = /mnt/cache/rclone/cache-backend
chunk_path = /mnt/cache/rclone/cache-backend
workers = 10
chunk_no_memory = true
writes = true
plex_token = *REDACTED*

[local]
type = local

Rclone mount:

rclone --rc --rc-user=redacted --rc-pass=redacted --rc-web-gui --rc-web-gui-no-open-browser --rc-addr 0.0.0.0:5572 --rc-web-gui-force-update \
mount --uid 99 --gid 100 --allow-other --vfs-cache-mode writes --cache-writes data-cache: /mnt/cache/data &

Script:

./rclone-cache_torrents.sh

Here is the result (log):
Script Starting May 06, 2020 16:00.01

Full logs for this script are available at /tmp/user.scripts/tmpScripts/10_cache_torrents/log.txt

1/4 "Kung.Fu.Panda.2008.MULTi.1080p.BluRay.HDLight.x265-H4S5S.mkv" in "data/transmission/radarr"
	File 1/1 Kung.Fu.Panda.2008.MULTi.1080p.BluRay.HDLight.x265-H4S5S.mkv:
		-> File already fully cached, nothing to do

2/4 "Captain.America.Civil.War.2016.1080p.Multi.Bluray.HDLight.x265.HEVC-SN2P.mkv" in "data/transmission/radarr"
	File 1/1 Captain.America.Civil.War.2016.1080p.Multi.Bluray.HDLight.x265.HEVC-SN2P.mkv:
		-> File already fully cached, nothing to do

3/4 "En Avant [FR-EN] (2020).mkv" in "data/transmission/radarr"
	File 1/1 En Avant [FR-EN] (2020).mkv:
		=> File not fully cached, caching full file
{
	"status": {
		"transmission/radarr/En Avant [FR-EN] (2020).mkv": {
			"Error": "",
			"FetchedChunks": 141
		}
	}
}


4/4 "The.Call.of.the.Wild.2020.MULTi.1080p.10bit.WEBRip.HEVC.x265-NoTag.mkv" in "data/transmission/radarr"
	File 1/1 The.Call.of.the.Wild.2020.MULTi.1080p.10bit.WEBRip.HEVC.x265-NoTag.mkv:
		-> File already fully cached, nothing to do

Script Finished May 06, 2020  16:00.38

Full logs for this script are available at /tmp/user.scripts/tmpScripts/10_cache_torrents/log.txt

Script Starting May 06, 2020  16:01.01

Full logs for this script are available at /tmp/user.scripts/tmpScripts/10_cache_torrents/log.txt

1/4 "Kung.Fu.Panda.2008.MULTi.1080p.BluRay.HDLight.x265-H4S5S.mkv" in "data/transmission/radarr"
	File 1/1 Kung.Fu.Panda.2008.MULTi.1080p.BluRay.HDLight.x265-H4S5S.mkv:
		-> File already fully cached, nothing to do

2/4 "Captain.America.Civil.War.2016.1080p.Multi.Bluray.HDLight.x265.HEVC-SN2P.mkv" in "data/transmission/radarr"
	File 1/1 Captain.America.Civil.War.2016.1080p.Multi.Bluray.HDLight.x265.HEVC-SN2P.mkv:
		-> File already fully cached, nothing to do

3/4 "The.Call.of.the.Wild.2020.MULTi.1080p.10bit.WEBRip.HEVC.x265-NoTag.mkv" in "data/transmission/radarr"
	File 1/1 The.Call.of.the.Wild.2020.MULTi.1080p.10bit.WEBRip.HEVC.x265-NoTag.mkv:
		-> File already fully cached, nothing to do

4/4 "En Avant [FR-EN] (2020).mkv" in "data/transmission/radarr"
	File 1/1 En Avant [FR-EN] (2020).mkv:
		-> File already fully cached, nothing to do

Script Finished May 06, 2020  16:01.01

(starting/finishing time and full logs are provided by my OS script scheduler)

I have some I/O error with high speed concurrent downloads on transmission...

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.