Improved concurrency for Heroku Dynos
A Rack application running on heroku can improve performance by using different application servers with different performance characteristics.
Some good choices include Thin (evented I/O), Unicorn (multi-process) and Puma (multi-threaded).
The exact configuration settings will vary by application and how much memory each app takes. A default Rails app with a basic scaffold can easily support 4 unicorn workers or 4 puma threads. A small Sinatra app can support several times that number.
Here are the Procfile
settings you can use for each:
# thin
web: bundle exec thin -p $PORT -e $RACK_ENV start
# puma
web: bundle exec puma -t 1:4 -b tcp://0.0.0.0:$PORT
# unicorn
web: bundle exec unicorn -p $PORT -c ./config/unicorn.rb
Use the New Relic RPM Add-on to monitor your application resources.
Written by Phil Cohen
Related protips
1 Response
Just a +1 here for Puma. You've got to spend more effort in making your app thread safe, but the pay off is huge.
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Ruby
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#