Question

I am new to Ruby on Rails and beginning a project soon. Having read about different Ruby implementations, I am wondering which setup to use. My project is expected to have a fair amount of traffic.

I am considering two optiosn: MRI Ruby (v 2.0) and JRuby (v 1.9). I am concerned that MRI Ruby is not multithreaded and am worried about the impact this will have on the web app. Perhaps the application server can eliminate this problem? Right now it looks like we will be using Puma as the application server.

In short, should I use JRuby because it is multithreaded on 1.9 or should I use MRI Ruby on 2.0?

Was it helpful?

Solution

TL;DR

Using either Puma or Passenger negates this issue because they handle threads on their own. I would recommend working with the newest version of Ruby and Rails possible as this will minimize the upgrade work you need to do when upgrading your app.


Here is a wonderful article which addresses your issue.

To summarize.

Puma is multithreaded-only. The open source variant of Phusion Passenger is multi-process single-threaded. The Enterprise variant can be configured to be either single-threaded or multithreaded.

...

Both Puma and Phusion Passenger Enterprise can be hybrid multi-process multi-threaded. That is, running multiple multithreaded processes. Hybrid mode allows Ruby and Python, which despite having a Global Interpreter Lock, to fully utilize all CPU cores.[1] In Puma, the hybrid mode is called "clustered". [1] Only the case on MRI, not on JRuby and Rubinius. JRuby and Rubinius fully support multi-core threads in a single process.

In other words, both Puma and Passenger are able to treat any Ruby implementation as multi threaded. They do this by using a hybrid between multiple processes and multiple threads. This is only minimally heavier than simple multi-threading.

To be honest, I don't think this is an issue you need to worry about at this time. Wait to see how your server handles the site's traffic.

OTHER TIPS

Honestly, if you are new to Ruby and Rails, just stick with the defaults - MRI in this case. Ruby enjoy several great implementations (MRI, JRuby, Rubinius, ...) that will run your web application without any problem. Starts with MRI, you can always decide to change later if needed.

You will be in a much better position to judge what is the best Ruby implementation and server when the work on your application will have started - more proficient on the plateform, and more aware of your specific challenges (not every application is that dependent on multi threading performance).

Enjoy the road!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top