Search code examples
ruby-on-railsnginxheroku

Using Heroku and PostgreSQL, do I still need Nginx?


I'm new to rails, I have an existing rails project developed by my friend.

He was using Nginx and unicorn for the Web server and MySQL database. On the other hand, I decided to use Heroku, PostgreSQL and Unicorn. Do I still need Nginx for the setup?

I have done some research but I'm not sure if I'm understanding it correctly.

Nginx is an HTTP server and Unicorn is a web application server, It seems we should include them all in production but I'm not quite sure.


Solution

  • nginx is the actual HTTP server (the machine - virtual or no) which stores and serves your files. Heroku offers hosting of these files on their servers, which means that the HTTP server part of your problem is solved.

    To have a fully functional application you need both a HTTP server which stores and serves your files and an application server (sort of like a container for your application) which supports serving dynamic pages (in our case through ruby code). Since Heroku takes care of the HTTP server, you only need to worry about the application server.

    As stated by johnheroy, Heroku will use WEBrick by default if nothing is specified - but nothing is keeping you from using a multi-threaded server like Puma or multi-processed Unicorn. You can even have Puma running multi-processed and multi-threaded (you can even use Passenger - a more hybrid HTTP/Application Server), which is what we do on our team.

    Suggested reading: Puma running on Heroku