<br><br><div class="gmail_quote">On Wed, Jun 22, 2011 at 3:33 PM, Vassilis Bekiaris <span dir="ltr"><<a href="mailto:v.bekiaris@saicon.gr">v.bekiaris@saicon.gr</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<u></u>
<div bgcolor="#ffffff" text="#000000">
Hi!<br>
<br>
recently (on another unrelated thread) an issue came up with failure
to open sockets due to the limit of file descriptors available per
user per process (this was on Ubuntu linux IIRC), could this be your
case? Check this article by Trustin for further reading:<br>
<br>
<a href="http://gleamynode.net/articles/1557/" target="_blank">http://gleamynode.net/articles/1557/</a><br>
<br>
Cheers,<br>
Vassilis</div></blockquote><div><br></div><div>Turns out my issue was that Fedora ships with a default 'user process' limit of 1024 - which is roughly threads in java.</div><div><br></div><div>So that solves the crashing OOM/no-more-threads problem. My next question is this: </div>
<div><br></div><div>Why are so many threads created? My experience in other event-driven networking systems (eventmachine, libev, libevent, etc) is that only 1 thread (or only a few) are used to process network IO; in Netty, using the Executors.newCachedThreadPool it seems to make 1 thread per server socket. If I switch to using newFixedThreadPool(N) only the first N sockets are usable.</div>
<div><br></div><div>I feel like I'm doing something wrong here; should I be expecting a 1:1 thread:socket mapping? That seems odd.</div><div><br></div><div>-Jordan</div><div><br></div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div bgcolor="#ffffff" text="#000000"><div><div></div><div class="h5"><br>
<br>
On 23/06/2011 1:14 , Jordan Sissel wrote:
</div></div><blockquote type="cite"><div><div></div><div class="h5">Howdy :)
<div><br>
</div>
<div>I have a service that currently listens on thousands of tcp
and udp ports (for different channels of data); due to various
problems, I am rewriting it in Java and decided to use Netty.</div>
<div>
<br>
</div>
<div>I've tried a few different ways of doing things -</div>
<div><br>
</div>
<div>First, one NioServerSocketChannelFactory (or
NioDatagramChannelFactory) per listening port. Problem is, after
a few thousand server channels (via ConnectionlessBootstrap and
ServerBootstrap), I get OOM while creating threads.</div>
<div><br>
</div>
<div>Second, one NioServerSocketChannelFactory shared across all
TCP server ports and one NioDatagramChannelFactory for all UDP
server ports. Problem here is that after about a few hundred
open sockets with error
"org.jboss.netty.channel.ChannelException: Failed to bind to: /<a href="http://0.0.0.0:15725" target="_blank">0.0.0.0:15725</a>"
- watching strace shows bind(2) successfully bind on this port,
for example, so the cause is not a bind specific failure.
Trolling the logs, I see about 911 successful TCP server sockets
before tcp fails with this message</div>
<div><br>
</div>
<div>I am using NioServerSocketChannelFactory with
Executors.newCachedThreadPool().</div>
<div><br>
</div>
<div>I can try to make some standalone code that reproduces this
behavior for further study, but if there's anything obvious I'm
missing, please let me know.</div>
<div><br>
</div>
<div>-Jordna</div>
</div></div><pre><fieldset></fieldset>
_______________________________________________
netty-users mailing list
<a href="mailto:netty-users@lists.jboss.org" target="_blank">netty-users@lists.jboss.org</a>
<a href="https://lists.jboss.org/mailman/listinfo/netty-users" target="_blank">https://lists.jboss.org/mailman/listinfo/netty-users</a></pre>
</blockquote>
</div>
<br>_______________________________________________<br>
netty-users mailing list<br>
<a href="mailto:netty-users@lists.jboss.org">netty-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/netty-users" target="_blank">https://lists.jboss.org/mailman/listinfo/netty-users</a><br></blockquote></div><br>