Executing unit tests occurs Too many open files error
m-t-a-n-a-k-a opened this issue · 3 comments
Errno :: ENFILE: Too many open files in system - socket (2) error occurs when unit test is executed.
I changed the maximum number with the ulimit command but it still fails.
Is there a way to fix this error?
$ ulimit -n
10000
Failures:
1) echo client/server should send/receive 10,000 messages
Failure/Error: socket = ::Socket.new(*args)
Errno::ENFILE:
Too many open files in system - socket(2)
# ./lib/async/io/socket.rb:88:in `initialize'
# ./lib/async/io/socket.rb:88:in `new'
# ./lib/async/io/socket.rb:88:in `build'
# ./lib/async/io/socket.rb:108:in `connect'
# ./spec/async/io/c10k_spec.rb:66:in `block in echo_client'
Finished in 3.74 seconds (files took 0.88211 seconds to load)
24 examples, 1 failure
Failed examples:
rspec ./spec/async/io/c10k_spec.rb:112 # echo client/server should send/receive 10,000 messages
My enviroment:
Operating System: OS X Yosemite 10.10.2
There are two issues. On macOS sometimes there is a hard limit that ulimit can't bypass, it must be changed in launchd config. Secondly, 10000 might not be enough since there are probably at least 20000 sockets required for the c10k spec, e.g. 10000 connections with one socket on the server and one socket on the client + a handful of server sockets for listening/accepting connections.
Thanks for your replay.
As you pointed out, I solved the problem by creating limit.maxfiles.plist.
Excellent. Let me know how you get on with this family of gems :) I'm always happy to hear about how it's being used or if you have any problems.