Live data from Hacker News

Solid Queue 1.6.0 now supports fiber workers

github.com

21–30 of 41 posts

Re: Solid Queue 1.6.0 now supports fiber workers

#21

As someone who spent 15+ years doing Ruby/Rails, it’s nice to see this land. That said, these days you’ll pry the BEAM from my cold, dead hands. It’s hard to go back to any other concurrency story.

Ironically, looking into Ruby Fiber led me to BEAM/Elixir. You are right, there is no going back!

Re: Solid Queue 1.6.0 now supports fiber workers

#22
post #14
post #8

Earlier quoted context omitted.

It’s more like goroutines or other lightweight concurrency mechanisms. If threads are OS-level concurrency primitives, fibers are scheduled within Ruby itself, which makes them much more efficient than threads. In fact, I got the following results in HTTP benchmark tests: Go: * Latency under stable load: p95 0.25–5.32 ms, p99 2.20–9.92 ms * Memory: 23–31 MB RSS across HTTP scenarios Ruby: * Latency under stable load:…

I'm unclear on the relevance of a comparison between Go and Ruby here. Ruby is radically slower than Go. It's down there with Python, if not a touch behind [1]. From the outside, I'd expect that it's possible that slight improvements in the context switching time will be dwarfed by the generally slow execution of Ruby itself; that is, if Ruby is going to take 100 microseconds to do something, whether it context switc…

It was mostly HTTP/JSON tests with some sort of validation, basic auth and logging. I think Ruby is used the most for this. I see many companies switching from Ruby to Go or FastAPI for this basic web services stuff, and I have no idea why. Ruby needs to improve its memory management, but the speed is pretty good.

Re: Solid Queue 1.6.0 now supports fiber workers

#23
post #8
post #3

So fibers are a lot like threads but they're more scoped to a task that can be paused and resumed, that's kinda cool

It’s more like goroutines or other lightweight concurrency mechanisms. If threads are OS-level concurrency primitives, fibers are scheduled within Ruby itself, which makes them much more efficient than threads. In fact, I got the following results in HTTP benchmark tests: Go: * Latency under stable load: p95 0.25–5.32 ms, p99 2.20–9.92 ms * Memory: 23–31 MB RSS across HTTP scenarios Ruby: * Latency under stable load:…

How much load? How many concurrent connections? What machine? Don’t get me wrong, benchmarks like these are useful to help ballpark performance floors, but really only relevant for a given load scenario. They don’t mean a lot without context. Not an attack by the way, just feedback.

Re: Solid Queue 1.6.0 now supports fiber workers

#25
post #9

Earlier quoted context omitted.

I don't know Solid Queue or the rails environment, but I expect that not every worker will create it's own connection, there should be a connection pool in-between

I think by default they check out a new connection when obtained a job and then release it. In comparison with some async languages like JS where a connection is only checked when a query is about to be executed

this used to be the case in Rails, but hasn't been for at least a year. Nowadays each framework-controlled action (like record.save) checks out a connection and then returns it back; this was implemented as part of the whole "run rails in fiber-based server" push

Re: Solid Queue 1.6.0 now supports fiber workers

#27

As someone who spent 15+ years doing Ruby/Rails, it’s nice to see this land. That said, these days you’ll pry the BEAM from my cold, dead hands. It’s hard to go back to any other concurrency story.

Same path & agreed. The amount of things you do not have to care about with BEAM/Elixir compared to Rails is really interesting.

I’m really curious about this as someone that has never tried Elixir/BEAM.

What could I stop caring about?

Re: Solid Queue 1.6.0 now supports fiber workers

#28

As someone who spent 15+ years doing Ruby/Rails, it’s nice to see this land. That said, these days you’ll pry the BEAM from my cold, dead hands. It’s hard to go back to any other concurrency story.

Same path & agreed. The amount of things you do not have to care about with BEAM/Elixir compared to Rails is really interesting.

>BEAM/Elixir compared to Rails

Compared to Ruby. Elixir land doesn't have something similar to Rails, and phoenix is not it.

Re: Solid Queue 1.6.0 now supports fiber workers

#29
post #11
post #5

My concern is number of database connections. In the example it's 100 fibers per worker, at that rate you are going to exhaust db connections sooner. Happy to be wrong.

Carmine (which coded this Fibers update) wrote about this in his blog. See the section 'The database connection math'. And no, you won't have one connection per fiber. The difference is staggering when you compare to threaded mode: it requires 1,320 database connections to run the same benchmark that the fiber mode runs with 60. https://paolino.me/solid-queue-doesnt-need-a-thread-per-job/

Pretty sure that is entirely an unfair comparison. You don't need a connection per thread either. It is common to have web servers handles thousands of requests per second with a connection pool size of 20. As long as the handler threads borrow a connection for only a little time and block waiting for a connection while other threads are doing their thing, it works out fine.

There is absolutely no logical reason why database pool sizing could be a reason for preferring fibers over threads.

Post reply on HN