Reputation: 2749
Is anyone running SQLite in-memory db as their main database for their web app? I'm trying to get a handle on the feasibility/stupidity of such a setup.
If I have a web application with fewer than 500 concurrent users and a database that's smallish in size (between 0 and 4 GB), what's the feasibility of running SQLite in-memory with the entire database in it as the main database for the app?
Running in-memory would obviously make the "Durable" aspect of ACID difficult, but with the SQLite backup API, it seems like it's possible to keep an in-memory db in sync with a file-based db. I'm thinking that when a user executes a Save/Update/Delete command, it could instantly update the in-memory copy and then be queued to make it to the file-based db. Whenever the app gets cycled, it could just be loaded from the file-based db via the backup API, right?
According to the SQLite documentation, a single connection must be kept open in order to keep the in-memory db up and running, so is this a problem if it's kept open for hours or days?
Upvotes: 0
Views: 751
Reputation: 3068
You should only use an in-memory database for data processing, not to store data. Because you need to store the data on disk anyway, it's much simpler and more effective to store the database on disk in the first place.
Upvotes: 1
Reputation: 182769
If you need to sync the database to disk, why use an in-memory database? The advantage of an in-memory database is that data never needs to be written to a filesystem. Since you need data to be written to disk, you've turned the sole advantage into a disadvantage. So why do it? Just crank up the cache as large as you can.
Upvotes: 0