我的理解是,當我擁有與我的內核一樣多的工作人員時,應該默認處理傳入請求。爲什麼我看到請求只能同步處理?我有8個CPU核心和8個獨角獸工作者 - 爲什麼不同時處理請求?
這裏是我的unicorn.rb:
worker_processes 10
APP_PATH = "/var/www/myapp/current" # available in 0.94.0+
APP_PATH_SHARED = "/var/www/myapp/shared"
working_directory APP_PATH
# listen on both a Unix domain socket and a TCP port,
# we use a shorter backlog for quicker failover when busy
listen "/tmp/.sock", :backlog => 64
listen 8080, :tcp_nopush => true
# nuke workers after 30 seconds instead of 60 seconds (the default)
timeout 60
# feel free to point this anywhere accessible on the filesystem
pid APP_PATH_SHARED + "/pids/unicorn.pid"
# By default, the Unicorn logger will write to stderr.
# Additionally, ome applications/frameworks log to stderr or stdout,
# so prevent them from going to /dev/null when daemonized here:
stderr_path APP_PATH_SHARED + "/log/unicorn.stderr.log"
stdout_path APP_PATH_SHARED + "/log/unicorn.stdout.log"
# combine Ruby 2.0.0dev or REE with "preload_app true" for memory savings
# http://rubyenterpriseedition.com/faq.html#adapt_apps_for_cow
preload_app true
GC.respond_to?(:copy_on_write_friendly=) and
GC.copy_on_write_friendly = true
before_exec do |server|
ENV['BUNDLE_GEMFILE'] = "/var/www/myapp/current/Gemfile"
end
before_fork do |server, worker|
# the following is highly recomended for Rails + "preload_app true"
# as there's no need for the master process to hold a connection
defined?(ActiveRecord::Base) and
ActiveRecord::Base.connection.disconnect!
# Before forking, kill the master process that belongs to the .oldbin PID.
# This enables 0 downtime deploys.
old_pid = APP_PATH_SHARED + "/pids/unicorn.pid.oldbin"
if File.exists?(old_pid) && server.pid != old_pid
begin
Process.kill("QUIT", File.read(old_pid).to_i)
rescue Errno::ENOENT, Errno::ESRCH
# someone else did our job for us
end
end
end
after_fork do |server, worker|
defined?(ActiveRecord::Base) and
ActiveRecord::Base.establish_connection
end
這已經困擾了我好幾個星期了!謝謝。
你可以張貼一些輸出被展示請求正在同步處理而不是同時處理? –
您是否正在生產? – jokklan
你使用的ruby版本是什麼? – tbem