当我的网站获得了很高的流量,我看到了定期通过谷歌Analytics(分析)和这种在nginx的错误日志错误滴:
App 17888 stderr: [ 2014-02-22 17:02:23.5307 19258/0x0000000609a820(Worker 1) utils.rb:68 ]: *** Exception Errno::ECONNRESET in Rack body object #each method (Connection reset by peer) (process 19258, thread 0x0000000609a820(Worker 1)):
App 17888 stderr: from /usr/lib/ruby/vendor_ruby/phusion_passenger/utils/unseekable_socket.rb:114:in `write'
App 17888 stderr: from /usr/lib/ruby/vendor_ruby/phusion_passenger/utils/unseekable_socket.rb:114:in `write'
App 17888 stderr: from /usr/lib/ruby/vendor_ruby/phusion_passenger/rack/thread_handler_extension.rb:141:in `block in process_request'
App 17888 stderr: from /home/ubuntu/.rvm/gems/ruby-1.9.3-p484/gems/activerecord-3.2.12/lib/active_record/query_cache.rb:46:in `each'
App 17888 stderr: from /home/ubuntu/.rvm/gems/ruby-1.9.3-p484/gems/activerecord-3.2.12/lib/active_record/query_cache.rb:46:in `each'
App 17888 stderr: from /home/ubuntu/.rvm/gems/ruby-1.9.3-p484/gems/activerecord-3.2.12/lib/active_record/connection_adapters/abstract/connection_pool.rb:460:in `each'
App 17888 stderr: from /home/ubuntu/.rvm/gems/ruby-1.9.3-p484/gems/rack-1.4.5/lib/rack/body_proxy.rb:31:in `each'
App 17888 stderr: from /usr/lib/ruby/vendor_ruby/phusion_passenger/rack/thread_handler_extension.rb:140:in `process_request'
App 17888 stderr: from /usr/lib/ruby/vendor_ruby/phusion_passenger/request_handler/thread_handler.rb:142:in `accept_and_process_next_request'
App 17888 stderr: from /usr/lib/ruby/vendor_ruby/phusion_passenger/request_handler/thread_handler.rb:110:in `main_loop'
App 17888 stderr: from /usr/lib/ruby/vendor_ruby/phusion_passenger/request_handler.rb:441:in `block (3 levels) in start_threads'
我认为这是关系到开放套接字或其他东西的数量,我不知道到底。 所以,问题是这是什么,我怎么能解决这个问题。
这是关于我的服务器和应用程序的一些信息:
Nginx的:
- worker_processes:32
- worker_connections:4096
- passgener_max_queue_size:0
- passenger_max_pool_size:75
- passenger_min_instances:75
扶手:
- ActiveRecord的池大小:16(这是太小了?)
服务器:
- 32个CPU
- 60GB拉姆
我也增加了允许500K开放套接字的数量,允许300K的打开的文件数。