Hi all,
My first post here, i hope it in the correct location.
What would be the correct location for holding ~150 files totaling ~300Mb in a “ram drive” that should never hit physical storage. The files are temporary .ts / .m3u8 files for a simple “live camera system”. The video streams are not recorded, the files live for about 70 seconds and then get removed, there is no desire for any persistent storage.
- ffmpeg captures an rtsp stream from a camera and transcodes it into .ts segments / updates the m3u8 “playlists” on disk in a sub directory of the Nginx web-root.
- Nginx hosts a simple website with hls-js ( GitHub - video-dev/hls.js: HLS.js is a JavaScript library that plays HLS in browsers with support for MSE. ) that serves it all up in a webbrowser.
- The desire is to make a persistent mountpoint from fstab to a sub-folder inside the web-root so ffmpeg can write, and Nginx can serve the content.
The above setup chewed up it’s first ssd i had laying around in about 2 months, given it’s age i did not think much about it, and replaced it with a new ssd drive and called it a day. Just shy of a year passed, and it went down again with a broken storage. So i sent the drive in for repair, and got a no warranty reply. reason: It had used all it’s write endurance ?!?.
Looking back it made sense quickly, the above writes about 300Mb/min to storage, in a month that makes ~13TiB, the 250GiB Samsung 980 drive has a warranty for 5 years OR 150 TBW, oops… i did not think of that.
A quick google for with keywords as “tmpfs / ramdrive / best practice” resulted in a lot of confusing pointers from sites like stack exchange and the likes. What i have found (not-)suggested so far:
- /tmp → This is just a folder on the os drive that serves as a common place for any temporary files.
- /var/tmp → Same as /tmp, just a longer retention time?
- /dev/shm → many sites have different views it seems, some claim trouble as it is intended for POSIX C lib only, others say it can be used safely as it’s just a tmpfs mountpoint?
- Any “tmpfs” implementation → Should not be used? Because it may still cause swapping to disk? even if enough free ram exists?
- Any “ramfs” implementation → Should not be used? Because it may steal memory from the kernel in certain conditions? apparently as a result potentially causing the same swapping?
Most sites that tried providing info as mentioned above had some links to other sites to “empower” statements made, though on a global view, there seems to be no clear path or way to handle my use case, most reasoning for using ram drives seems to be for performance reasons, not to save storage write endurance, i have also seen suggestions / hints at using “direct storage in ram” potentially is unsafe and could open up security holes… all in all… what seemed to be a simple question… turned confusing.
So what would be the correct “ram drive” to create the mount in the web-root in a way that is safe, provides me the filesystem like mount / bind / loop device so i can keep from doing needless (in)direct writes to physical storage and allow ffmpeg to write and nginx to read as it is right now?
Thanks for any pointers / solid advice that leads to a clear choice in finding a "correct way "to decide how to do this seemingly simple thing
Steven