I made some performance and stress tests with the juggernaut server,
and was unable to connect with more than 1024 clients . In the EM docs
there's the solution: use epoll() instead of select() - but it
requires a 2.6 kernel.
http://www.rubyeventmachine.com/browser/trunk/EPOLL
Here's a patch, that makes EM use epoll() instead of select().
Depending on the current Linux distribution and configuration, you
might have to edit /etc/security/limits.conf
and one lines above the "# End of File" add the following two lines
* hard nofile 65535
* soft nofile 65535
(including the stars!)
On some distributions (e.g. Ubuntu) you also have to add the following
line
session required pam_limits.so
to the file /etc/pam.d/common-session .
Then reboot...
This step is only necessary, if the output of "New descriptor-table
size is..." is still lower than what was defined as parameter.
Index: lib/juggernaut/runner.rb
===================================================================
--- lib/juggernaut/runner.rb (revision 131)
+++ lib/juggernaut/runner.rb (working copy)
@@ -62,10 +62,16 @@
stop
exit
}
-
+
+ if options[:descriptor_table_size]
+ EM.epoll
+ new_size =
EM.set_descriptor_table_size( options[:descriptor_table_size] )
+ logger.debug "New descriptor-table size is #{new_size}"
+ end
EventMachine::run {
EventMachine::add_periodic_timer( options[:cleanup_timer].to_i )
{ Juggernaut::Client.send_logouts_after_timeout }
EventMachine::start_server(options[:host],
options[:port].to_i, Juggernaut::Server)
+ EM.set_effective_user( options[:user] ) if options[:user]
}
end
@@ -105,6 +111,10 @@
opts.on("-p", "--port PORT", Integer, "Specify port",
"(default: #{options[:port]})") do |v|
options[:port] = v
end
+
+ opts.on("-s", "--fdsize FILE_DESCRIPTOR_SIZE", Integer, "Set
the file descriptor size (e.g. 60000) and use epoll() on a 2.6 Linux
kernel ", "(default: use select() which is limited to 1024 clients")
do |v|
+ options[:descriptor_table_size] = v
+ end
opts.separator ""; opts.separator "Daemonization:"
Alex, maybe you could merge this into the trunk?
thanks, Heiko