I was deploy rails aplication on the basic droplet. There are nginx, ruby 2.0.0 through rvm, rails 4.0.1, foreman. All of this deploy with capistrano 3. When I start unicorn instances, they take all of the free CPU and CPU load is 100% whole time untill unicorn work. There is my unicorn.rb: worker_processes 4
working_directory “/var/www/apps/estate/current” # available in 0.94.0+
listen “/var/www/apps/estate/socket/.unicorn.sock”, :backlog => 64 listen 8080, :tcp_nopush => true
timeout 30
pid “/var/www/apps/estate/run/unicorn.pid”
stderr_path “/var/www/apps/estate/log/unicorn.stderr.log” stdout_path “/var/www/apps/estate/log/unicorn.stdout.log”
preload_app true GC.respond_to?(:copy_on_write_friendly=) and GC.copy_on_write_friendly = true
check_client_connection false
before_fork do |server, worker|
defined?(ActiveRecord::Base) and ActiveRecord::Base.connection.disconnect!
old_pid = “#{server.config[:pid]}.oldbin” if old_pid != server.pid begin sig = (worker.nr + 1) >= server.worker_processes ? :QUIT : :TTOU Process.kill(sig, File.read(old_pid).to_i) rescue Errno::ENOENT, Errno::ESRCH end end end
after_fork do |server, worker|
defined?(ActiveRecord::Base) and ActiveRecord::Base.establish_connection
end What might be wrong with my settings?
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Try using NewRelic or a similar service to find out where the bottleneck is, they offer a 14-day free trial.
I had the same problem. In my case it was some gems missing. After I installed them Unicorn took up not more than 0.3% CPU.
The problem was unclear since unicorn error log file didn’t show me anything. I tried to run Thin server instead and got nice “Can’t load” errors in its logs.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.