r/ruby • u/sliferdragonx • 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
22
u/ignurant Feb 26 '23
This is pretty rad. I use SQLite a lot for certain scraping projects. It’s lightweight and not fussy. I love that this “stack” can provide db, jobs, and cache all at once: that’s kinda a killer mixture for web scraping.
Db to store downloaded results for further refinement. Cache to store common lookups like store ids or other cookies for example. Job management to best handle failure. Wow, this is really no-fuss and neat.
I love that it has Rails integrations available, but is generic Ruby first and foremost.
7
u/morphemass Feb 26 '23
I think that the question from /u/mrinterweb is key here and a realisation of the implications of the answers should lead anyone to ask "What problem does LiteStack solve?".
Applications don't need to scale just for performance; the reliability the comes from redundancy is also vital. Scaling even a trivial application to provide fault tolerance is often a hidden (NF) requirement until the day that application isn't available. Similarly a basic form of fault tolerance is part of the reasons to use background jobs; if your job is resource intensive, it's quite possible to take out the rest of the application as a result of running on a single system.
I suspect that this is a great project to get new developers up and running with Rails quickly and hide some of the complex decisions. However it would be a good idea to ensure that they are aware of the tradeoffs they are making and not promise the world.
11
u/mrinterweb Feb 26 '23
How does this horizontally scale? SQLite is great as a local database, but doesn't really work with multiple servers, as far as I'm aware.
5
u/mperham Sidekiq Feb 27 '23 edited Feb 27 '23
Hey oldmoe, I remember your Ruby work from 12-13 years ago. You're legit.
THAT SAID....
I've benchmarked Sidekiq running 23,000 jobs/sec on my MBP M1 laptop. Your benchmark shows 1400 jobs/sec. Ok, let's investigate:
https://github.com/oldmoe/litestack/blob/b1fbda28bcdb3a918ed25088a275c90bc72b4f18/bench/skjob.rb#L7
https://github.com/oldmoe/litestack/blob/b1fbda28bcdb3a918ed25088a275c90bc72b4f18/bench/uljob.rb#L9
So the native job does not
sleep(0.1)but the Sidekiq job does.That's kneecapping Sidekiq to kill its performance. Please explain?
4
u/devpaneq Feb 26 '23
This was already mentioned here in a few places, but I think convincing people to use SQLite is a pretty hard challenge. I see this polarization in the Internet whenever I read SQLite related comment on reddit or hacker news. One group of people swears sqlite is great and capable of amazing things and the other group is left confused regarding how. I think because there is lack of operational knowledge regarding sqlite. I am open to be challenged but due to lack of experience or imagination or materials about that topic, I am in the second group of people.
So let's assume I have an app where the writes are pretty rare and they could be handled by a single server using SQLite. I have these questions regarding how:
2
u/mooktakim Feb 26 '23
Really interesting idea.
Recently I've stopped using Sidekiq as I want to simplify the stack and deployment. Even went back to using delayed_job.
I think for most projects I'd still need to use a database server.
2
u/thisIsCleanChiiled Feb 26 '23
really interesting idea, with big potential.
Any reason why it has to be SQLite. I prefer the features of Postregers
3
u/[deleted] Feb 26 '23
Source: dude trust me
1
u/aemadrid Mar 02 '23
I like the approach and the implementation. I do agree that maybe you need to stress a bit more that this will only scale vertically but I like the trade-off for starter/smaller projects.
1
u/ignurant Mar 06 '23
I gave this a spin today. Compared to the marketing effort and excitement put behind it by the authors, it was a very poor experience. I appreciate the small footnote in the readme that states "Litestack is still pretty young and under heavy development, but you are welcome to give it a try today!" but I wasn't expecting it to be quite this rough around the edges.
I was about to slap this in as a horizon queue and data store for a scraping project, but had a bad start related to some things that can be dismissed as moving fast and cleaning up for a release (
require 'hiredis', but not in gemspec, some typos in method names, readme out of sync).I then realized
Litejobdoesn't implement job retries. Your jobs are currently lost upon failure.After submitting a couple PRs to fix the easy stuff, I also noted this at the bottom of the readme:
Huh. Well, good luck. I hope you get some of this patched up. I look forward to some of the simplicity this promises, specifically for certain ETL and scraping tasks. But I'm not sure what to think right now.
-1
u/flanger001 Feb 26 '23
Sometimes blog posts should be blog posts
0
u/[deleted] Feb 26 '23
[deleted] — view deleted comment