On 13/05/07, Marcin Raczkowski <swistak / mailx.expro.pl> wrote:
> On Friday 11 May 2007 08:25, J. Wook wrote:
> > Simple test codes are here:
> >
> >
> > class TestServer
> >   include DRb::DRbUndumped
> >
> >   def initialize
> >     @obj = Array.new
> >   end
> >
> >   def register(addr)
> >     @obj << addr
> >   end
> >
> >   def sum
> >     s = 0
> >     @obj.each do |t|
> >       v = DRbObject.new_with_uri(t).get_value
> >       if v.nil?
> >         puts s.to_s + " & error"
> >       end
> >       s += v
> >     end
> >     return s
> >   end
> > end
> >
> > class TestClient
> >   include DRb::DRbUndumped
> >
> >   def initialize(addr, server, value)
> >     DRbObject.new_with_uri(server).register(addr)
> >     @value = value
> >   end
> >   def get_value
> >     @value
> >   end
> > end
> >
> >
> > uri = "druby://localhost:"
> > server_uri = uri + "40000"
> > server = DRb.start_service(server_uri, TestServer.new)
> >
> > max_size = 300
> >
> > (1..max_size).each do |t|
> >   client_uri = uri + (40000 + t).to_s
> >   DRb.start_service(client_uri, TestClient.new(client_uri, server_uri,
> > t))
> > end
> >
> > sum = DRbObject.new_with_uri(server_uri).sum
> > puts sum
> >
> >
> > For max_size = 10, sum = 55
> > For max_size = 100, sum = 5050
> >
> > ...
> >
> > but
> >
> > For max_size = 300,
> > DRb::DRbConnError exception raised.
> >
> > try to make another DRb server after that error in the same process....
> > #<Errno::EMFILE: Too many open files - socket(2)> raised.
> >
> >
> > How can I open more than 300 DRb connection?
> > (I need to make about 1,000 connections .... )
>
> question probably everyone want's to ask.why the hell you need 1000
> connections? dont' tell me you have 1000 servers with drbservers running
> somewhere
>

It's been said that it's some 250 connections. For one, the
application might act as some sort of proxy which would double the
number of sockets.

Apparently it either uses some other files of uses about 4
handles/connection. It looks quite a lot and could be probably lowered
but it does not change the fact that 1000 is a safe default for
non-server applications but can be easily reached by servers.

I wonder why such limits are imposed. It is probably some workaround
for a flaw in UNIX design that introduces possible DoS by exhausting
kernel memory/structures. Maybe it was fixed in some kernels (if
that's even possible) but nobody cared to fix the limit as well.

Thanks

Michal