Hope you enjoyed our previous blog for setting up the rails app using Nginx and Unicorn .
In this series, today we are going to cover Puma . Puma has gained quite popularity among rails developer in recent time so we thought, its worth writing about puma as Rails Developer.
Why Puma ??
As the rails framework got matured over the time, its app servers also got evolved. There are couple of options available when you look for deploying your rails app. Passenger, Unicorn, Thin and Puma. Puma got quite popular over last year. Heroku also recommend using puma for its Cedar platform.
Puma is fast, threaded and highly concurrent server. For best throughput it is recommend to use Ruby implementation with real thread like Rubinius or JRuby. You can scale puma on thread level as well as worker level.
For a quick look about puma's comparison with its other counterparts, visit http://puma.io/ .
Prepare your instance/server for deployment.
Please follow below steps from our previous blog as they are not worth repeating here.
- Prepare your instance & Install dependent libraries
- Install Nginx
- Install Ruby
Add puma to your Gemfile and run bundle install
Add puma.rb in config/ directory of your application.
You are probably using capistrano or mina to automate your deployment. If so in that case please put puma.rb in shared/config and make sure your to create symbolik link in deployment script. I should probably have a separate blog for automating deployment.
Configure Nginx to use Puma
Considering you have adjusted db setting in config/database.yml and all other environment related changes, its time to start puma. Lets do it .
From root of your application directory, run below
bundle exec puma -C config/puma.rb
Its time to visit your site. Enjoy simple, fast, threaded and concurrent PUMA!!!!!!!!!