I have a Node.js application that heavily utilizes an SQLite database and I am worried about the impact it may have on my SSD.
My application periodically updates information about all clients that are connected to a certain server. I would rather not going into any specifics regarding the clients and/or server here.
Every 5 seconds, it performs an INSERT OR REPLACE
for each connected client. New clients are inserted and existing clients have their data replaced with more up-to-date data. A single row contains roughly 10kB worth of data and there can be up to 5,000 clients connected (= 5,000 rows inserted / replaced) at a time.
In Task Manager, I can see ~3MB/s disk usage in idle state and ~6MB/s when the update happens.
Should I be concerned about wearing down my SSD? If so, how can I minimize the wear?
Options like renting a server or building a redundancy RAID are not really available to me, so I am looking for a software solution. I have already tried setting journal mode
to WAL
and temp store
to memory
, but the temp store
always reverts to default
and the WAL journal mode
does not seem to have much of an effect in this regard.
I already use transactions, but I am afraid it may not be enough to solve the problem. Another obvious solution would have been to decrease the frequency, however this is not really an option for me as I need a database with as up-to-date data as possible.
I know there is the option for an in-memory database using :memory:
, but I have to store the client data across sessions. I need to load the existing client data from disk when the application initializes and I also need to periodically save the current state of the database to disk to avoid data loss in case of a power outage, an unexpected Windows update or something like that. Given how unlikely these events are to occur, it would be okay to do these backups to disk once per hour for example.
Is there any way to keep the database in memory for the most part and only synchronize it with a version on a physical disk during initialization and then every hour or so?