Hacker News new | ask | show | jobs
by lifo 4080 days ago
As someone who's done the bulk of the work for Action Cable, I wanted to clear the confusion re: cable and eventmachine. Cable is currently using EventMachine because it uses faye-websocket for dealing with websockets. And Faye is one of the very few well maintained ruby library dealing with websockets.

And in fact, Action Cable uses Celluloid threadpool to run all the application code in threads. So the model is a combination of EventMachine + Threads.

There's absolutely no reason it can't use Threads + Celluloid all the way. But building on top of Faye was the simplest way to get things up and running.

2 comments

As someone who's tried to use Faye and EventMachine (separately) back in the Ruby 1.9.3 days: Have they stabilized enough to be used for anything?

My memory of them is rather horrible.

Memory leaks, segmentation faults(!) and obscure deadlocks eventually made me scratch EventMachine from the list of things I'd ever want to touch again.

And Faye, well, I don't think I even got it fully running at the time. I still re-call my astonishment when I realized that neither of their two different server-impls at the time would pass even most basic tests (e.g. browser connect/disconnect, redis start/stop) without crashing, locking up or losing messages.

Admittedly it's been a while... Is anyone running Faye in production and can comment?

Edit: Thanks for the feedback. I guess it's time to give Faye a second chance.

You can't use Faye without eventmachine. Cable only uses faye-websocket though - https://github.com/faye/faye-websocket-ruby . Do let me know if you had any negative experiences with that. I don't know about the state of the things in the 1.9.3 days, but faye-websocket has always "just worked" for me.
I wrote http://firehose.io/ that runs on a separate fleet of servers to handle pub/sub that uses Faye. For the most part it runs without putting up a fuss.

Lost messages aren't a concern because it's assumed the protocol won't handle lost or dropped messages, so Firehose messages have a sequence that counts up per channel that the client keeps track of.

I've been using Faye quite happily for the last month or so and have been very pleased with it.
When I was building live relation system faye server has problem to accept more that 1k simultaneous connections. For nodejs it can accept about 30k simultaneous connections. Did you do some stress test with more that 1k connections?