Is puma the ONLY multi-threaded rails 4 http server?

No. In alphabetical order:

  • Iodine a HTTP / Websocket Server & EventMachine alternative (kqueue/epoll based)
  • Net::HTTP::Server, despite the lack of advertising, supports multithreading
  • Phusion Passenger has supported multithreading since v4 beta
  • Rainbows! supports multiple concurrency models, including multithreading
  • Reel is a Celluloid-backed “evented” server, which “also works great for multithreaded applications and provides traditional multithreaded blocking I/O support too”
  • Thin has a threaded mode, which can be enabled by passing --threaded or by setting threaded: true in the appropriate configuration file (e.g. bundle exec thin start --threaded)
  • WEBrick is on its own multithreaded, so it’s not fair to eliminate it as an option; if you’re using the Rails-embedded version, you’ll need to monkey-patch Rails::Server to enable multi-threading
  • Zbatery is based on Rainbows! and supports all concurrency models that Rainbows! supports

Note that currently MRI Ruby runs only one thread runs at a time due to its global interpreter lock (GIL). You’ll only be truly able to exploit multithreading by using a different Ruby runtime such as JRuby or Rubinius, which provide access to native threads. If you decide to go with JRuby, there are several JVM-dependent servers worth exploring.

Leave a Comment