Why does ruby rails need puma or unicorn?
Asked Answered
I

3

7

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

Imprecise answered 6/9, 2015 at 13:7 Comment(1)
You can use unicorn behind nginx proxy. It can help you handling many requestsPendergrass
F
11

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.

Fragrant answered 6/9, 2015 at 13:30 Comment(0)
M
3

Since you have worked with php backend, I assume you are familiar with modphp or fcgi modules. They are actual engines that compile and run php code. Ruby on rails cannot run on its own just like php. So there is need of something like puma, or phusion passenger to run it. They are called application server. You can use application server to serve website directly, but it is recommended approach. There are more suitable alternatives like nginx which have evolved just for this purpose.

Malleable answered 6/9, 2015 at 13:35 Comment(0)
G
0

I found a great article on this here https://www.rubyguides.com/2019/08/puma-app-server/

I also made this diagram with a very dumbed down list of the responsibilities of Web Servers, Application Servers, and Web Frameworks

enter image description here

Giuliana answered 28/12, 2021 at 15:56 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.