
In Unicorn terminology these are referred to as worker processes not to be confused with Heroku worker processes which run in their own dynos.Įach forked OS process consumes additional memory. Unicorn forks multiple OS processes within each dyno to allow a Rails app to support multiple concurrent requests without requiring them to be thread-safe. Unicorn worker processes worker_processes Integer(ENV || 3) To manually configure this value use heroku config:set WEB_CONCURRENCY. The environment variable WEB_CONCURRENCY will be set to a default value based on dyno size. For information on other available configuration operations, see Unicorn’s documentation. The above assumes a standard Rails app with ActiveRecord and New Relic for monitoring. Puts 'Unicorn worker intercepting TERM and doing nothing.

Puts 'Unicorn master intercepting TERM and sending myself QUIT instead'ĪctiveRecord::! For a simple Rails application, we recommend the following basic configuration: # config/unicorn.rb ConfigĬreate a configuration file for Unicorn at config/unicorn.rb, or at a path of your choosing.
#Define rails install
Run bundle install to set up your bundle locally. Adding Unicorn to your application Gemfileįirst, add Unicorn to your app’s Gemfile: gem 'unicorn' Unicorn is a Rack HTTP server that uses forked processes to handle multiple incoming requests concurrently. See Managing Multiple Environments for an App for more info. For basic Rails setup, see Getting Started with Rails.Īlways test your new deployments in a staging environment before you deploy to your production application. This guide will walk you through deploying a new Rails application to Heroku using the Unicorn web server. The Unicorn web server lets you run any Rails application concurrently by running multiple Ruby processes in a single dyno. But most Ruby applications don’t support this today. The framework is gradually moving away from this design towards a thread safe implementation that allows for concurrent processing of requests in a single Ruby process. The Rails framework was originally designed to process one request at a time. Therefore it is recommended to use concurrent request processing whenever developing and running production services. Web applications that process requests concurrently make much more efficient use of dyno resources than web applications that only process one request at a time.

If you are using Unicorn, your application is not protected against a slow client attack. Heroku recommends using the Puma web server instead of Unicorn.
