Is Puma better than Unicorn for Ruby 1.9.3 and Rails 3.2?

pratski picture pratski · Jul 31, 2013 · Viewed 8.6k times · Source

There is a lot of talk about Puma and how it is faster than Unicorn. But, they also mention that it is more suitable for instances of JRuby and Rubinius.

MY question: What about a Rails 3.2 app with Ruby 1.9.3? Unicorn or Puma?

Answer

Rajarshi Das picture Rajarshi Das · Jul 31, 2013

There is an great article for unicorn vs puma

http://ylan.segal-family.com/blog/2013/05/20/unicorn-vs-puma-redux/

Unicorn is a Rack HTTP server that uses forked processes to handle multiple incoming requests concurrently.

  1. Process management: Unicorn will reap and restart workers that die from broken apps. There is no need to manage multiple processes or ports yourself. Unicorn can spawn and manage any number of worker processes you choose to scale to your backend.
  2. Load balancing is done entirely by the operating system kernel. Requests never pile up behind a busy worker process.
  3. Does not care if your application is thread-safe or not, workers all run within their own isolated address space and only serve one client at a time for maximum robustness.
  4. Supports all Rack applications, along with pre-Rack versions of Ruby on Rails via a Rack wrapper.
  5. Builtin reopening of all log files in your application via USR1 signal. This allows logrotate to rotate files atomically and quickly via rename instead of the racy and slow copytruncate method. Unicorn also takes steps to ensure multi-line log entries from one request all stay within the same file.
  6. nginx-style binary upgrades without losing connections. You can upgrade Unicorn, your entire application, libraries and even your Ruby interpreter without dropping clients.
  7. before_fork and after_fork hooks in case your application has special needs when dealing with forked processes. These should not be needed when the “preload_app” directive is false (the default).
  8. Can be used with copy-on-write-friendly memory management to save memory (by setting “preload_app” to true).
  9. Able to listen on multiple interfaces including UNIX sockets, each worker process can also bind to a private port via the after_fork hook for easy debugging.
  10. Simple and easy Ruby DSL for configuration

    1. Decodes chunked transfers on-the-fly, thus allowing upload progress notification to be implemented as well as being able to tunnel arbitrary stream-based protocols over HTTP.

For Puma(Newer version of so called server mongrel)

Puma is a simple, fast, and highly concurrent HTTP 1.1 server for Ruby web applications. It can be used with any application that supports Rack, and is considered the replacement for Webrick and Mongrel. It was designed to be the go-to server for Rubinius, but also works well with JRuby and MRI. Puma is intended for use in both development and production environments.

Puma is favourite for speed and parallelism

If you want to see speed comparison then puma is best.

for more you can see http://puma.io/

Thanks