简体   繁体   中英

Rails deployment, bundle exec rails s vs Nginx and Passenger

I recently deployed a rails app to a ec2 instance on AWS. This was my first time doing deployment like this.

I was reading around and most sources seem to suggest rails deployment with Nginx and Passenger.

Right now I run bundle exec rails s -p 80 -b 0.0.0.0 and my app runs great when I go to my ec2 url.

I was wondering what are the upsides and downside of just running bundle exec rails s -p 80 -b 0.0.0.0 VS using Nginx and Passenger?

  1. Nginx and passenger will help load balancing, where you can more no of passenger to server request.
  2. If passenger died nginx will start new passenger.
  3. For deployment nginx and passenger is great way, starting server with 'rails s' and port no is good for development not for deployment.
    1. Https and other more option is available with nginx.
    2. web server and application server is good combination for deployment.

There are plenty of advantages to using NGINX and Passenger for your production environment vs rails s .

If you are using the standard WEBrick::HTTPServer for you rails s , you'll notice performance increases since NGINX and Passenger are highly optimized for this type of thing.

NGINX provides several config files where you can control virtual hosts and use it as a reverse proxy server ( http://nginx.org/en/docs/beginners_guide.html ). It is extremely fast at serving static assets. As mentioned--it provides several options (load balancing, gzip options, SSL and non-secure server block setups, caching, proxying requests).

Using NGINX with Passenger is extremely efficient as you can include Passenger in your NGINX config to automatically start your server with the set of options you need with Passenger. Passenger provides several configurations that you can use, such as, maximum/minimum amount of forked processes/threads you can have of your application and RAM limitations. Visit https://www.phusionpassenger.com/library/config/nginx/reference/ for a list of all of them. It can also restart your application when it crashes, which is also a great benefit.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM