News for hackers. Stuff that matters.
Re:A Deep Dive into Solid Queue for Ruby on Rails by nkraft11 on Monday June 23, 2025 @07:32PM (#44361299)
I briefly worked at a YC company that was a ruby shop. Their answer to every performance problem was to stick it on a queue. There were, I don’t know, dozens of them. Then they decided they needed to be multi-region, because reasons. But the queues weren’t set up to be multi-region, so they built an entirely new service that’s job was to decide which queue in which region jobs needed to go on. So now you had jobs crisscrossing datacenters and tracking any issue became literally impossible. Massively turned me off to both that company and ruby in general.
Re:A Deep Dive into Solid Queue for Ruby on Rails by cortesoft on Monday June 23, 2025 @07:41PM (#44361363)
Don't let one company's misuse of a language turn you off the entire thing!
Re:A Deep Dive into Solid Queue for Ruby on Rails by rubyfan on Monday June 23, 2025 @07:45PM (#44361385)
Yeah this is not the fault of ruby. Sounds more like bad choices that could be made with any language or framework.
Re:A Deep Dive into Solid Queue for Ruby on Rails by charcircuit on Monday June 23, 2025 @07:59PM (#44361467)
Culture around a language influences what choices are made.
Re:A Deep Dive into Solid Queue for Ruby on Rails by rubyfan on Monday June 23, 2025 @08:05PM (#44361498)
Don’t be silly. Bad choices are made in all sorts of languages and teams - this has nothing to do with language. High pressure situations can lead teams to make choices they don’t always foresee as bad until after they are paying the consequences.
Re:A Deep Dive into Solid Queue for Ruby on Rails by charcircuit on Monday June 23, 2025 @09:17PM (#44361952)
Sure bad choices are made everywhere, but I was essentially claiming that when a community has a hammer, they will see nails.
Re:A Deep Dive into Solid Queue for Ruby on Rails by rubyfan on Monday June 23, 2025 @09:34PM (#44362045)
Queues are not a ruby specific thing, nor are they particularly pervasive within Rails apps. Having a good framework to handle them doesn’t make it the only tool in the tool belt. On the contrary, the fact that Rails has good tools to fit many different types of system architecture needs is a counterpoint of your assertion.
Re:A Deep Dive into Solid Queue for Ruby on Rails by nkraft11 on Tuesday June 24, 2025 @09:29AM (#44366051)
Sort of. In this case the lack of multithreading led engineers to using sidekiq as a stand in.
Re:A Deep Dive into Solid Queue for Ruby on Rails by trevorhinesley on Monday June 23, 2025 @08:05PM (#44361501)
I’ve never felt like “throw everything into a queue” was a mindset within the Ruby community, nor have we done that at my companies. And multi-region is a business decision.
Re:A Deep Dive into Solid Queue for Ruby on Rails by morkalork on Monday June 23, 2025 @08:12PM (#44361540)
Doesn't Ruby, like Python, have a GIL? I always found that one is enough to encourage some "premature scalable architecture"
Re:A Deep Dive into Solid Queue for Ruby on Rails by trevorhinesley on Monday June 23, 2025 @08:25PM (#44361626)
It does have a GIL. You’re not wrong, but by that same logic, there’s pitfalls when using multi-threading as well, even in languages where it’s native (e.g., Elixir).

Regardless, in my experience, when you run into scenarios that need queueing, multi-threading, etc., you need to know what you’re doing.

Re:A Deep Dive into Solid Queue for Ruby on Rails by Lio on Tuesday June 24, 2025 @01:59AM (#44363233)
That depends on the Ruby implementation.

MRI (CRuby) has a GVL which is why you might use a forking web server like Puma or Pitchfork.

JRuby and TruffleRuby though have true multi-threading and no GVL.

I’ve used the Concurrent Ruby library with JRuby and Tomcat quite a bit and find works very well for what I need.

Re:A Deep Dive into Solid Queue for Ruby on Rails by aaronblohowiak on Monday June 23, 2025 @09:28PM (#44362003)
Resque was a staple for a long long time. In the jvm world, throw everything into Kafka is also a staple of a lot of "enterprise" shops. Or SQS for AWS places I've worked at. I think it is not a ruby language thing, but a certain kind of architecture thing.
Re:A Deep Dive into Solid Queue for Ruby on Rails by WillPostForFood on Monday June 23, 2025 @09:34PM (#44362049)
True that it is not uncommon to use Sidekiq or Resque , but Rails 8 is going to be the first version to ship with a queuing system (SolidQueue), later this year. So queueing has been an add-on for 20 years. I don't think it is quite a staple.
Re:A Deep Dive into Solid Queue for Ruby on Rails by ggsp on Tuesday June 24, 2025 @01:26AM (#44363080)
Rails 8 came out in November, and `rails new` generates an app with the solid trio in the Gemfile. Been fun playing around with it for new side projects :)
Re:A Deep Dive into Solid Queue for Ruby on Rails by atmosx on Tuesday June 24, 2025 @06:08AM (#44364532)
Funny part: I initially thought you were referring to the word “Byzantine” itself, which tends to carry a negative connotation in English, mostly due to historical bias. But you’re actually talking about Ruby!

If we were to take Byzantine in a more accurate, historical sense, something truly “Byzantine” should be evolving, enduring, top-tier, and built to last for 1k years.

Re:A Deep Dive into Solid Queue for Ruby on Rails by nkraft11 on Monday June 23, 2025 @10:41PM (#44362421)
You're totally correct. It's not a problem of ruby per se, but engineers would basically just throw their hands up and say "ruby can't handle this" and sidekiq became the One True Way™. What ensued was the most byzantine software architecture I've ever seen.
Re:A Deep Dive into Solid Queue for Ruby on Rails by trevorhinesley on Monday June 23, 2025 @07:43PM (#44361374)
Neither sticking everything into a queue nor going multi-region are Ruby’s fault.
Re:A Deep Dive into Solid Queue for Ruby on Rails by teaearlgraycold on Monday June 23, 2025 @07:42PM (#44361367)
Ruby and the age of “I don’t care what type this variable is, it quacks like a duck!” is over and dead. Improvements to type systems have shown there is a better way to do software development.
Re:A Deep Dive into Solid Queue for Ruby on Rails by ch4s3 on Monday June 23, 2025 @09:14PM (#44361934)
Maybe, the cycle has happened before and maybe come back around again. Dynamic typing is really nice when most of your data looks like bags of strings. Compilers and tools just don’t add a lot when you’re passing around glorified blobs of stringy json-like stuff. Type gymnastics can eat a lot of time where you could otherwise be shipping something useful.
Re:A Deep Dive into Solid Queue for Ruby on Rails by riffraff on Tuesday June 24, 2025 @12:52AM (#44362943)
I would argue when you're passing around stringy JSON-like thingies is when typing is most useful :)

You're not going to misuse an API that takes a Person or Cart, but mixing up two hashes cause you used two different strings as keys can happen easily.

(I do think dynamic typing is mostly fine, but I do wish ruby had optional static typing with some nice syntax instead of RBS)

Re:A Deep Dive into Solid Queue for Ruby on Rails by Lio on Tuesday June 24, 2025 @02:27AM (#44363368)
It’s on the way thankfully.

I’m really excited about Sorbet getting behind the new RBS-inline comment syntax and the prospect of both runtime and static analysis as optional tools when needed.

Re:A Deep Dive into Solid Queue for Ruby on Rails by ch4s3 on Tuesday June 24, 2025 @09:52AM (#44366279)
> You're not going to misuse an API that takes a Person or Cart, but mixing up two hashes cause you used two different strings as keys can happen easily.

This is more or less trivial to catch and fix, I'm just not sure a type system is worth it's weight for that kind of case.

Re:A Deep Dive into Solid Queue for Ruby on Rails by jaredsohn on Tuesday June 24, 2025 @02:54AM (#44363505)
I haven't really felt a need for static typing in my job's Rails app (small team, and I've been working in this codebase a really long time) but I think LLMs can be a huge help for automating the type gymnastics.
Re:A Deep Dive into Solid Queue for Ruby on Rails by AstroBen on Monday June 23, 2025 @09:29PM (#44362010)
Static typing isn't free. Dynamic typing is perfectly viable to build any sized software - there's living proof, far from dead

So we're only left with personal opinion

Re:A Deep Dive into Solid Queue for Ruby on Rails by sbarre on Monday June 23, 2025 @10:39PM (#44362406)
Or the standard "it depends" answer that everyone eventually realizes is the only correct answer. ;-)
Re:A Deep Dive into Solid Queue for Ruby on Rails by RangerScience on Monday June 23, 2025 @11:22PM (#44362610)
Typescript is literally a language describing what the quack “sounds like” so you can attempt to ensure any particular variable makes those kinds of quacks. Typescript doesn’t care that it also quacks like a dog.

Plus, Ruby has lots of easy ways for you to check typing, if you want to.

Re:A Deep Dive into Solid Queue for Ruby on Rails by throwaway493943 on Monday June 23, 2025 @09:01PM (#44361860)
I'm going to be brave (but still use a throwaway) and ask the dumb question - what is wrong with putting things in queues to help with performance problems?

If some endpoint is too slow to return a response to the frontend within a reasonable time, enqueueing it via a worker makes sense to me.

That doesn't cover all performance issues but it handles a lot of them. You should also do things like optimize SQL queries, cache in redis or the db, perhaps run multiple threads within an endpoint, etc. but I don't see anything wrong with specifically having dozens of workers/queues. We have that in my work's Rails app.

Happy to hear how I can do things better if I'm missing something.

Re:A Deep Dive into Solid Queue for Ruby on Rails by RangerScience on Monday June 23, 2025 @11:14PM (#44362580)
I think your question is well-asked, and I lament any work environments that have led you to think asking a question like this would be A Problem(tm).

IMO - there’s a lot of things that queues are an excellent answer to. Potentially including performance.

But - queues (generally and among other things) solve the problem of “this will take some time AND the user doesn’t need an immediate response.”

If that’s not your problem, then using queues might not be the solution. If it’s something that’s taking too long and the user DOES need a response, then (as you say) optimizing is what you should try, not queues. Or some product redesign so the user either doesn’t need an immediate response. Or finding a way to split up the part producing an immediate response and the part that takes awhile.

For example: validating uploaded bulk data is in the right “shape”, and then enqueuing the full validation and insertion.

Also really really avoid jobs that enqueue jobs. Sometimes they’re necessary (spacing out some operation on chunks of a group; or a job that ONLY spawns other jobs) but mostly they’re a route to spaghetti.

Re:A Deep Dive into Solid Queue for Ruby on Rails by jaredsohn on Tuesday June 24, 2025 @03:32AM (#44363721)
I made the original post.

At the time there were 5-10 posts (you can look at timestamps if you want to see) and they were all basically assuming that this YC startup misused Rails, etc while I view what they were doing as reasonable, to the extent I can tell.

Basically, if you need to do something that will time out or do something independent of user action, you'll be using enqueued jobs. If you're enqueuing a job because a request is slow and building a db index for it would make it fast, then you're doing things wrong but it isn't clear if that is happening.

Even the multi-region part doesn't seem too complex to me, although I've not had the need for it. I just asked an AI to build me some code for it; you just pass a customer-specific argument into each worker which then enqueues into the proper redis instance or whatever.

I've built jobs that enqueue other jobs and do it for the reasons you mentioned. Sometimes have jobs that do something and then enqueue another job. That happens since that second job might get run in other situations, as well. I don't see that as spaghetti.

Most of the jobs I've built are tracked in some db field to indicate if they were done or not. We'll want those things done and not care too much about when. That seems like a simple concept to me so those code that enqueues it isn't spaghetti in my opinion.

Re:A Deep Dive into Solid Queue for Ruby on Rails by zdragnar on Monday June 23, 2025 @09:48PM (#44362129)
There's two primary areas that I've seen teams get bitten by this personally:

1) Designers don't understand that things are going to happen async, and the UI ends up wanting to make assumptions that everything is happening in real time. Even if it works with the current design, it's one small change away from being impossible to implement.

This is a general difficulty with working in eventually consistent systems, but if you're putting something in a queue because you're too lazy to optimize (rather than the natural complexity of the workload demanding it) you're going to be hurting yourself unnecessarily.

2) Errors get swallowed really easily. Instead of being properly reported to the team and surfaced to a user in a timely manner, the default setting of some configurations to just keep retrying the job later means if you're not monitoring closely you'll end up with tens of thousands of jobs retrying over and over at various intervals.

Re:A Deep Dive into Solid Queue for Ruby on Rails by bigtunacan on Monday June 23, 2025 @11:31PM (#44362645)
We have 100s of queues processing millions of jobs in sidekiq queues at any given time.

These are data and compute heavy workloads that take anywhere from minutes to hours for a request to be completed, but the UI takes this into account.

Users submit a request and then continue onto whatever is the next thing they intend to do and then they can subscribe to various async notification channels.

It’s not the right choice for everything, but it’s the right choice for something’s.

Re:A Deep Dive into Solid Queue for Ruby on Rails by nkraft11 on Monday June 23, 2025 @10:38PM (#44362402)
Error handling was a huge issue, along with other weird distributed system bugs. Backed up queues, job shedding, thundering herds, you name it. When you have jobs on queues kicking off new jobs on different queues, tracing issues is just miserable. Sure, it's not a problem of ruby per se, but engineers would basically just throw their hands up and say "ruby can't handle this" and sidekiq became the One True Way™.
Re:A Deep Dive into Solid Queue for Ruby on Rails by pmontra on Tuesday June 24, 2025 @12:28AM (#44362864)
Maybe "ruby can't handle this" was a short form for "we can't run this in the Rails controller because the response would take too long" possibly calling 3rd party APIs, "and we would run out of threads."

Anything running in sidekiq is written in Ruby too.

Re:A Deep Dive into Solid Queue for Ruby on Rails by Lio on Tuesday June 24, 2025 @02:16AM (#44363315)
These are good points, in answer to them:

1. Yes this is true but Rails now comes with nice support for async UI built to push updates to the browser via Hotwire and Turbo.

You’d need something like that anyway anytime you’re calling an external service you don’t control.

2. Again this is also a good point but even running every request synchronously you still need good error logging because you don’t want to share details of an error with your frontend.

With background jobs you definitely need to be on top of monitoring and retry logic. I also think you need to be very careful about idempotency amd retry logic.

I see that as the engineering trade offs for that pattern. There’s very little in the way of silver bullets in engineering; different solutions just come with different trade offs.

Re:A Deep Dive into Solid Queue for Ruby on Rails by rubyfan on Monday June 23, 2025 @09:26PM (#44361993)
You’re not missing anything and are correct in that there are plenty of reasons to use queues and defer work that can be handled asynchronously outside of a request/response. This is not specific to ruby or any language for that matter.

The parent indicated the cross region dynamic required extra routing logic and introduced debugging problems.

Re:A Deep Dive into Solid Queue for Ruby on Rails by teyc on Monday June 23, 2025 @09:19PM (#44361961)
Queues have several problems - if the caller is http it may timeout and retry, leading to more jobs being queued - the caller may no longer care because it took so long and the work is wasted - if the caller is called from a queue it can cause cascades - you can fill a disk up and crash the system
Re:A Deep Dive into Solid Queue for Ruby on Rails by crowcroft on Monday June 23, 2025 @10:34PM (#44362389)
To me the question is, so what's a better alternative? At least queues can be designed to handle timeouts, errors, and flakey APIs.
Re:A Deep Dive into Solid Queue for Ruby on Rails by hobs on Monday June 23, 2025 @10:20PM (#44362325)
Pretty simple - people often think queues are magic, and an unbounded queue is just your previous problem but now way worse; what happens when the queue "gets full"?

But if you are just smoothing out some work its pretty normal, just make sure you are modeling things instead of putting it in the magic queue.

Re:A Deep Dive into Solid Queue for Ruby on Rails by pmontra on Tuesday June 24, 2025 @12:22AM (#44362826)
We were offloading to jobs every long running activity in the Elixir/Phoenix project I've been working on years ago. There is no other way. The response to a web request must complete in a short time and free the server for further requests.

We solved debugging by sending all log lines to a centralized server. We were running on the Google cloud.

We were not multiregion though.

My current Rails project uses sidekiq a lot to send mail, generate PDFs, any activity that does not have to necessarily complete before we return the response. We keep the interactive web app up to date by websockets and with callbacks for clients using our public API. I don't think we would have done it differently in any other language.

By the way, we built our slimmer version of sidekiq for Elixir because the language plus the OTP libraries have a lot of functionality but we still need to persist jobs, retry them even after a complete reboot, exponential back off, etc.

Re:A Deep Dive into Solid Queue for Ruby on Rails by yxhuvud on Tuesday June 24, 2025 @06:42AM (#44364720)
Bad architecture can happen in any language. I don't see how the language choice could ever protect you against the described structural problem you built.

Also you will see that the answer to most actual performance problems tend to be queues even in other languages. At least in mature places - mostly because it is possible to inspect what a queue is doing. Though it will of course be a problem if it is part of a big spaghetti architecture.