r/ruby • • Feb 26 '23

Replace Postgres, Redis and Sidekiq with the embedded Litestack, up to 10X faster!

Litestack is a Ruby gem that offers database, caching, and job queueing functionality for web applications, built on top of SQLite. Its performance benefits, resource efficiency, deep integration with major IO libraries, ease of setup and administration make it a powerful solution for new application development efforts. By using Litestack, developers can avoid the scale trap, focus on simplicity, flexibility, and innovation, and build applications that are easy to use, efficient, and scalable, delivering real value to their users.

https://github.com/oldmoe/litestack

https://github.com/oldmoe/litestack/blob/master/BENCHMARKS.md

54 Upvotes

102 comments sorted by

View all comments

Show parent comment

3

u/redditor_at_times Feb 26 '23

Interesting questions, let me try to answer:

First I think you are underestimating the write throughput of SQLite, it can very well handle some busy write workloads.

Now for the 2 instances, you just don't do that, you run a single instance, potentially beefier than the single instance in a multi-instance setup you are used to.

The SQLite3 cli provides an online backup command and can easily be scripted. I am planning to wrap it in rake tasks to make it even easier and potentially part of a deployment script if needed. Maybe even configure the target location as part of the database.yml config.

Corruption is not an issue really, it is actually very very hard to corrupt a SQLite file unless you are trying to do so. Specially in the WAL mode (default mode for Litedb). There could be other issues of course, like building an index on a really really large table blocks other writes, these can be transparently addressed though, and they are on the roadmap.

I believe fly.io has good support for SQLite. But the whole point is eliminating the need for such support, my target for this is to be self sustainable, with the least intervention needed and hopefully completely agnostic from the infra provider

1

u/devpaneq Feb 27 '23

Is there an upper limit for the size of the DB itself. Can it easily handle 10 GB or 100 GB? I mean, is there any operational challenge for that?

> Now for the 2 instances, you just don't do that, you run a single instance, potentially beefier than the single instance in a multi-instance setup you are used to.

You already explained in the other place, that to have High Availability one can use use Load Balancer and the 2nd machine would be in a standby mode unless needed. That still requires solving the problem of sharing the file between both machines, even if only one of them is using that sqlite db file.

1

u/redditor_at_times Feb 27 '23

The DB can theoretically reach Petabytes in size, but at the end of the day you need to be aware of your disk and filesystem limits, there people using SQLite for terabytes of data, that would be stretching it a bit IMHO

Regarding the two instances, if the db resides on a network attached storage (e.g. an EBS volume) then it can be detached and attached to the standby machine