Hi, i’m about to start a small experiment on persistence.
Basically i need to save a switch state every time the state changes - won’t happen often, i think 5-6 time per year.
I have two questions, probably the second has already been discussed so sorry if i din’t find it in the forum
1 - while reading persistence specs, i saw there are many ways to enable this feature.
But which one has the less I/O on disk? For example mysql makes a lot of I/O in my experience and probably for my
project is not the best choice (my oh2 runs on sd card)
2 - is there a way to store a variable on a file and read it later? I think that in this moment enable persistence on my system is excessive for my purposes.
What makes you think a standard database (like MySQL) would produce much I/O in your setup? If you configure any perstence to store only when a state changes and expect those to happen only 5-6 times a day the I/O should be limited to that number.
Even for the use on a SD the required operations shouldn’t be to much.
From my experience - i wrote years ago an application that write/read 20 times per day on mySQL, was running on a raspi w/ sd card. This setup was for my irrigation control system.
What can i say… maybe my code was not efficient, but every year i had to change sd due to sd corruption.
Another question: how can i read how much I/O i have on the sd? So i can measure this parameter before and after mySQL installation.
That probably had as much if not more to do with the logs than that many writes for the DB.
You can use iotop which works kind of like top or htop but shows file system activity rather than processor/ram usage.
But realize that it only shows you activity at that instant in time, not over long periods of time. And in my experience when nothing on the system is doing much processes will jump around all over the place but that is just noise as far as I can tell. When everyone is writing nothing of very little something causes them to move around.
But, based on many many topics I can say the following:
the SD card WILL fail, so you must have a good backup procedure
if you have a good backup procedure, do you really need to spend the effort to stretch the life of the SD card a few weeks or months?
@rlkoshak you’re absolutely right. I backup the SD eaach 10 days more or less so i’m far from totally destroy my installation!
Anyway: even if the entire community says that SD fail is common, except fom the one with the mentioned mySQL installation i never got a single sd failed. I’m a lucky man!
Indeed. I run one of my RPis mostly read only and it still had an SD card failure from the writes needed to update. It took a couple of years, but it still eventually failed.