Could you please help me with below mount command. Does anyone know why is RAM filled with around 40Mb on single mount? I'm trying to mount 2000 similar commands on same VPS. It's working, but my RAM is full on 99% and swap file bigger than 80gb.
I would like to use only 1Mb of RAM usage per single mount (i mean RAM usage when mount don't do anything and just "waits" for tasks). Any help would be appriciated.
Your mount command will keep a full directory listing of all the files in your mounts in RAM due to --dir-cache-time 1h and the default --poll-interval 1m.
Each directory entry takes roughly 2K, so the mount taking 40MB RAM probably has 20,000 files in it. All your mounts probably have 40M files in total (80G/2K).
I guess you can make your mount use minimal RAM by using:
--dir-cache-time=0s --poll-interval=0
You may however want to make it more responsive by caching directory listings in use in e.g. 1 minute, that is:
--dir-cache-time=1m --poll-interval=0
The mounts may read the directory listings at startup, so perhaps you need to start them with some delay in-between.
Rclone will use less RAM if you use the rc to mount multiple mounts in one rclone process.
Also have you investigated the combine backend - maybe that could help?
If use of each of those 2000 mount commands is only used intermittently, then you'd be better off using autofs to mount each rclone mount when it is in use only. This is a bit fiddly to set up but it will work a lot better than starting 2000 mounts.
Yes it does keep a list of files in RAM. I'd set --dir-cache-time to lower, but not 0 as that will cause lots of extra work for rclone fetching the directory listing every time. Maybe --dir-cache-time 60s might be a sensible minimum. Setting --poll-interval 0 probably doesn't make too much difference on memory as all it does is flush things from the dircache, but having 2000 background polls running will use lots of CPU.
On further though autofs is definitely the answer to this problem. That is why it was invented so you could have a lab/research group/university full of NFS mounts and not have to have all of them mounted all of the time.
I've always used --poll-interval 0, because the data in my read-only media mount never changes from within. Memory usage tops out at around a gig, but of course my use-case is entirely different