Thank you Trustin.<div><br></div><div>Yes, you are right as well ;) It took a while, but I learned this through trial, error, and learning.</div><div><br></div><div>This is what I've learned, and it took a while for me to wrap my head around these concepts:</div>
<div><br></div><div>a)</div><div><br></div><div>A non-blocking SocketChannel does not multiplex (and it doesn't need to), it only writes or reads what it can, telling you how much it wrote or read (which might be zero).</div>
<div>But while it is doing its write or read, during that exact moment, it is indeed blocking. In that situation, my multithreaded application X might have another thread that needs</div><div>to use of the channel (this makes it appear more lively). If I want application X to be more lively, it will need a pool of socket channels. </div>
<div><br></div><div>In netty terms, I'll need a pool of netty clients that talk to my netty server.</div><div><br></div><div>b)</div><div><br></div><div>To make the client friendly to multi-thread calls to it, it should respond with a future instead, so that it does not need to block within its call. Let the consumer decide what to do with the extra time.</div>
<div><br></div><div><br></div><div>Again, thank you Trustin, excellent work. Please let me know if you're ever in Los Angeles, I'll schedule you for an LAJUG presentation.</div><div><br></div><div>-Marco<br><br><div class="gmail_quote">
On Tue, Jun 21, 2011 at 2:45 AM, "이희승 (Trustin Lee)" <span dir="ltr"><<a href="mailto:trustin@gmail.com">trustin@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im">Marco Villalobos wrote:<br>
> I have a question on proper use of netty with protocol buffers.<br>
> I made extensive use of the LocalTime example in the documentation.<br>
><br>
> And I have some questions about best practices.<br>
><br>
> Let's say that there is a multithreaded application called X in which<br>
> many threads needs to make client calls to the netty server.<br>
><br>
> And we are using protocol buffers nio with netty.<br>
><br>
> FIRST QUESTION<br>
><br>
> In application X, how many clients should it use?<br>
><br>
> a) ONE client<br>
> b) A pool of clients?<br>
<br>
</div>If there are not many instances of application X connecting to the<br>
server, you could keep a pool of clients to get better throughput by<br>
utilizing more cores of the server. Otherwise, the server load will<br>
overweigh the throughput gain.<br>
<div class="im"><br>
> SECOND QUESTION<br>
><br>
> In the example,<br>
><br>
> <a href="http://docs.jboss.org/netty/3.2/xref/org/jboss/netty/example/localtime/LocalTimeClientHandler.html" target="_blank">http://docs.jboss.org/netty/3.2/xref/org/jboss/netty/example/localtime/LocalTimeClientHandler.html</a><br>
><br>
> Would this be an inefficient implementation of a handler considering<br>
> that it will block at line 71 ?<br>
<br>
</div>Handler itself does not call that method at all. It's the main thread<br>
that calls it. Therefore, I wouldn't say it's inefficient. If you have<br>
to deal with multiple connections and requests, it will be inefficient<br>
and you will have to make it asynchronous.<br>
<br>
HTH<br>
<font color="#888888"><br>
--<br>
Trustin Lee, <a href="http://gleamynode.net/" target="_blank">http://gleamynode.net/</a><br>
<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>
</font></blockquote></div><br></div>