3 ms·
How do you deal with common sqlite lock file when using it for multiple users?
by escovabr 5y ago
How do you deal with common sqlite lock file when using it for multiple users?
- ilrwbwrkhv 5y agoNot a problem up to 100,000 customers imp
- Jnr 5y agoI used it 10 years ago and initially locks were a slight problem. Not sure if this has been solved somehow in sqlite itself. I solved the problem by handling all the DB operations in a separate thread that handled write and read queues. It certainly was not as easy as using mysql/postgresql where server does everything for you. Nowadays there are probably plenty of libraries that handle that for you.
- Moto7451 5y agoThis pattern is what I did when I used SQLite in production. I used a lightweight actor model microframework to make it easier to route write requests from multiple areas of the code to the single writer thread and offer a continuation (or async/await) perform any follow up actions. Performance easily went beyond the requirements for the app.
- zo1 5y agoI'm not sure how to express my reaction to this kind of design/architecture without being rude. Especially with performant open source databases being available. Was this some sort embedded app or toy project?
- benbjohnson 5y agoWAL mode has been added in the last 10 years which handles read concurrency really well IMHO. You’re still constrained to a single writer but that’s not usually a problem as long as you keep your write transactions short.
- ta988 5y agoI solved that once by having a service layer on top of the db. Just a simple REST-like API used by the redt of the app (in Spring).