Since a few weeks I’m working on a Node.js project at my day work, and I kind of loved the idea of the event loop, and then, because I just got off a Rails project, was wondering why wouldn’t that be possible with Ruby?
Googled a couple of evenings to find how Node.js manages to serve multiple requests on the same thread, and how its IO works. Then did the same for Ruby, read a bit about GIL, and found that in the end, there is not that much of a difference between what you can get from a threaded Ruby server and Node.js.
Played a bit with hello worlds and ended up with similar results from the speed and concurency standpoint: max 2 concurent requests on my 2CPU laptop.
For Ruby I spawn a separated Thread for every request. And from what I could google, Node.js uses a thread pool to handle the IO and one single other to run JS, which is kind of similar as far as I can understand these things. Now, I’ve tried hello world Rails and Sinatra projects, and couldn’t get any concurrency: requests were basically serialized.
So here is what ab -n 1000 -c 10 http://127.0.0.1:2345/
have shown me. I’ve run every one of the tests a few times, and the results jump around but are basically pretty close.
Now, the question I don’t have answered yet is: is this approach used somewhere in Ruby web servers?