Hacker News new | ask | show | jobs
by ajsharp 4376 days ago
Theoretically, the number of puma threads you're running should be the same as the number of unicorn processes. That is, equal to the number of available CPU cores on the machine. So, if you're running on a machine with 8 cores, you should run 8 process or threads.

What continues to be the major issue with anything thread-based in ruby is that to reliably reach desired performance at load in a threaded setup, you need to be running an interpreter than can make concurrent use of native system threads. MRI has a global interpreter lock, so two pieces of ruby code will not run at the same time. IO is not subject to the GIL, so a lot of what happens in a web app can run concurrently (DB calls, etc), but other things that all happen in ruby (routing, view rendering) cannot.

So, basically, to reliably achieve similar performance using threads, you need to be using Rubinius or JRuby, which don't have a GIL.