title: Optimizing Heroku, Rails, and Unicorn: defining proper configuration options like how many worker processes?
body: <p>We have the following configuration file for Unicorn. We're on Rails 3.2.12 and Mongoid 3.1.16. How should we determine how many worker processes to use? Are there other options we could include to boost performance?</p>
  
  <p>Thanks!</p>
  
  <pre><code># config/unicorn.rb
  worker_processes Integer(ENV["WEB_CONCURRENCY"] || 3)
  timeout 25
  preload_app true
  
  before_fork do |server, worker|
    # TERM signals indicates the Heroku Dyno is shutting down
    Signal.trap 'TERM' do
      puts 'Unicorn master intercepting TERM and sending myself QUIT instead'
      Process.kill 'QUIT', Process.pid
    end
  end
  
  after_fork do |server, worker|
    # TERM signals indicates the Heroku Dyno is shutting down
    Signal.trap 'TERM' do
      puts 'Unicorn worker intercepting TERM and doing nothing. Wait for master to send QUIT'
    end
  end
  </code></pre>