title: Avoid SSD wear when using SQLite database in Node.js
body: <p><strong>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.</strong></p>
  
  <p>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.</p>
  
  <p><strong>Every 5 seconds</strong>, it performs an <code>INSERT OR REPLACE</code> for each connected client. New clients are inserted and existing clients have their data replaced with more up-to-date data. A single <strong>row contains roughly 10kB worth</strong> of data and there can be up to 5,000 clients connected (= <strong>5,000 rows inserted / replaced</strong>) at a time.</p>
  
  <p>In Task Manager, I can see ~3MB/s disk usage in idle state and ~6MB/s when the update happens.</p>
  
  <p><strong>Should I be concerned about wearing down my SSD? If so, how can I minimize the wear?</strong></p>
  
  <p>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 <code>journal mode</code> to <code>WAL</code> and <code>temp store</code> to <code>memory</code>, but the <code>temp store</code> always reverts to <code>default</code> and the <code>WAL journal mode</code> does not seem to have much of an effect in this regard.</p>
  
  <p>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.</p>
  
  <p>I know there is the option for an in-memory database using <code>:memory:</code>, 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.</p>
  
  <p><strong>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?</strong></p>