Re:Ask HN: Do you self-host your database?
by escovabr on Tuesday June 29, 2021 @06:29AM
(#27673995)
How do you deal with common sqlite lock file when using it for multiple users?
[ Parent
| on HN ]
I 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).
Re:Ask HN: Do you self-host your database?
by ilrwbwrkhv on Tuesday June 29, 2021 @07:27AM
(#27674369)
Not a problem up to 100,000 customers imp
I 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.
Re:Ask HN: Do you self-host your database?
by benbjohnson on Tuesday June 29, 2021 @09:40AM
(#27675612)
WAL 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.
Re:Ask HN: Do you self-host your database?
by Moto7451 on Tuesday June 29, 2021 @09:13AM
(#27675307)
This 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.
I'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?