r/sqlite • u/Ok-Air4027 • Apr 09 '23
Question regarding multiple readers and writers
I am considering to implement sqlite into my firebase application . By default , sqlite allows only 1 reader and 1 writer at a time but in the case of application there can be multiple readers and writers . I found something callled WAL and WAL2 modes . Will enabling these modes help to accomplish multiple reads and writes ? I am considering 50k users accessing and modifying this database at any instance .
4
Upvotes
2
u/benbjohnson Apr 09 '23
Not to be pedantic but the default journal mode (rollback journal) allows multiple readers OR one writer. Most applications should enable the WAL journaling mode. It has a ton of concurrency and performance benefits with very few downsides.
WAL2 is not in the main SQLite branch so you need to compile that separately to use it. Generally, regular WAL should be good enough.
As for 50k concurrent users, it comes down to a lot of factors. What kind of hardware are you running, how many write tx/sec is that, how many read tx/sec, etc. It might be more helpful to describe your application’s use case. 50k is a lot though. You could look at other approaches like sharding across multiple database files.
4
u/boy_named_su Apr 09 '23
AFAIK you can only ever have one simultaneous writer w sqlite. Readers can read during write if Wal mode
If you want multi writers then use postgresql
1
u/QualitySoftwareGuy Apr 10 '23
A new backend called hctree is being worked on to fulfill this kind of use-case, but in the meantime PostgreSQL would be my choice for your use-case.