Question

When my website got high traffic, I saw drops periodically via Google Analytics and this kind of error in nginx error logs:

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'

I think this is related to number of open sockets or something else, I dont know exactly. So the question is what is this, how can I solve this.

This is some informations about my server and application:

Nginx:

  • worker_processes: 32
  • worker_connections: 4096
  • passgener_max_queue_size: 0
  • passenger_max_pool_size: 75
  • passenger_min_instances: 75

Rails:

  • activerecord pool size: 16 (is this too small?)

Server:

  • 32 CPUs
  • 60GB Ram

I also increased the number of open sockets allowed to 500K, number of open files allowed to 300K.

Was it helpful?

Solution

ECONNRESET is a normal socket error that just means the client closed the connection before the request/response cycle is finished. You can safely ignore it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top