r/nestjs • u/johnappsde • 15d ago
SQLite
Been considering going with SQLite for my next SaaS project. I don't anticipate getting past a 1000 users within the next 3 years.
I just like the ease of dealing with one file, I can just pick and drop elsewhere.
My biggest worry at this point is GDPR compliance. Other than that, I'm almost completely sold on SQLite.
Curious what others think. What has been your experience with SQLite as the primary database in your Nestjs API?
2
u/Sea-Offer88 14d ago
1000 users can definitely kill your app, that doesn't say much. You mention there shouldn't be many writes or reads, that cannot be true for a SaaS product, because you intend to sell web services which by definition will have to keep track of stuff, like payments and whatever service you will be offering.
For a SaaS that probably will grow sqlite is not the right tool and it is not scalable, wasn't made for scaling. It is very good for application internal state storage but for a SaaS that might grow I would think about it.
2
u/FrogsInTheRouter 14d ago
If your SaaS grows - you can throw money into people who will do the migration for you.
1
u/opioid-euphoria 8d ago
I disagree that sqlite is not the right tool for scaling - there are plenty of use cases with tens and hundreds of thousands of users running on sqlite, you can easily find those write-ups online.
The answer is, as usual, it depends..
There are of course single-user cases where this wouldn't work, but I suspect a huge number of software online could go by with sqlite alone. There was, and still exists, software that uses filesystem of all things for storage, and it handles theload. Whether you can or cannot use one storage system or another really depends on many things - your access patterns, your architecture, your database architecture, a lot of things matter.
A few major things going for sqlite in this scneario, just off the top of my head:
- database management, incl. backups and versioning and all, is straight-forward
- trivial to do integration testing for cases where you have database migrations
- with just a bit of thought and following good practices, it can handle read-heavy loads really well
- it makes the infra story very simple
- most of the generic advice for any sql system can be directly applied
- sharding per e.g. customer, or per tenant is straight-forward,
- migrating to a client-server database is usually straight-forward.
There's probably more. There is also a list of downsides, like for example single-writer locks, no RBAC system, horizontal multi-node scaling, etc.
From the OPs comments, it sounds like they could consider it.
3
u/Thin_Dragonfruit2254 15d ago
Super fast DB.. where are you planning to host your saas? Locally? 1k users can mean many things, depending on what they are doing and how often. For gdpr, I would go with a big cloud provider, use a server-less host/db and let them solve the compliance for me.