Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does ruby rails need puma or unicorn?

In php, you only need apache or nginx. Why does ruby rails also need something like puma or unicorn when nginx is already installed?

like image 950
Kiwo Tew Avatar asked Sep 06 '15 13:09

Kiwo Tew


People also ask

What does Puma do in Rails?

Puma is a small library that provides a very fast and concurrent HTTP 1.1 server for Ruby web applications. It is designed for running Rack apps only.

What is Unicorn and Puma?

Both Unicorn and Puma are web servers for Ruby on Rails. The big difference is that Unicorn is a single-threaded process model and Puma uses a multithreaded model.

What is Unicorn in Ruby?

Unicorn is an HTTP server for Ruby, similar to Mongrel or Thin. It uses Mongrel's Ragel HTTP parser but has a dramatically different architecture and philosophy. In the classic setup you have nginx sending requests to a pool of mongrels using a smart balancer or a simple round robin.

Is Puma a web server or application server?

Puma is an HTTP web server derived from Mongrel and written by Evan Phoenix. It stresses speed and efficient use of memory.


1 Answers

This is not entirely correct, to run PHP with apache you will need either the apache mod_php or run it as a FastCGI module. For Nginx the latter seems to be the norm.

For Ruby there's Phusion Passenger that fills this role, and supports both apache and nginx. On apache it runs as a plugin module just the way mod_php does. For Nginx I'm not sure.

You may want to run your ruby applications using a dedicated application server, however. This is where Unicorn, Puma etc comes in. There's nothing preventing you from doing a similar setup for php, but it's less common.

Another thing which makes php easier to deploy in many cases is that most distros and server installs come with apache and nginx already set up to handle php, while you need to set this up on your own for ruby.

Once set up Passenger makes deploying ruby apps almost (but not quite) as simple as deploying php apps.

like image 71
harald Avatar answered Sep 21 '22 02:09

harald