May 16, 2015 by Daniel P. Clark

Switching From Unicorn to Puma on Heroku is Easy!

I’ve had my project running on Heroku with Unicorn for some time now.  Not that long ago Heroku put out a notice advising people to switch over to Puma as Unicorn doesn’t do well with low latency connections.  And you know that with the internet you’re always going to have people with slow connections accessing your service.  Also upon looking into it further Puma it looks like it performs better than all the other server control environments.  Puma’s key advantage being it does things with threads really well.

First I’ll show what I had for my Unicorn server setup.

Unicorn

The configuration file in config/unicorn.rb

The line in Procfile

And the Gemfile

From hear it was as easy as switching the Profile and Gemfile and adding a Puma config file.

Puma

The configuration file config/puma.rb

The only thing I had to change from the default was the environment variable used for the Redis server.

Changed the Profile to

And the Gemfile to

After that it’s the normal push to the Heroku server with git and everything works!

Summary

It’s easy, it’s better, so you might as well just go ahead and do it.  Feel free to look at Heroku’s howto if you’d like.  Deploying Rails Applications with the Puma Web Server  I’ve pretty much covered it here.

Please feel free to comment, share, subscribe to my RSS Feed, and follow me on twitter @6ftdan!

God Bless!
-Daniel P. Clark

Image by Tambako The Jaguar via the Creative Commons Attribution-NoDerivs 2.0 Generic License.

#change#easy#heroku#puma#rails#ruby on rails#switch#unicorn

2
Leave a Reply

avatar
1 Comment threads
1 Thread replies
0 Followers
 
Most reacted comment
Hottest comment thread
2 Comment authors
Daniel P. ClarkSwapnesh Khare Recent comment authors
  Subscribe  
newest oldest most voted
Notify of
Swapnesh Khare
Guest
Swapnesh Khare

I have a Rails app currently running on Unicorn. I want to shift to Puma in such a way that the heavy requests are directed to the Puma server and the rest run like before on Unicorn. I’m using nginx. Is it possible?

Daniel P. Clark
Guest

I don’t think that will work. The Procfile determines which process is used for “web” and your Rails instance handles requests there.