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&#39;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&#39;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&#39;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&#39;re ever in Los Angeles, I&#39;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, &quot;이희승 (Trustin Lee)&quot; <span dir="ltr">&lt;<a href="mailto:trustin@gmail.com">trustin@gmail.com</a>&gt;</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>
&gt; I have a question on proper use of netty with protocol buffers.<br>
&gt; I made extensive use of the LocalTime example in the documentation.<br>
&gt;<br>
&gt; And I have some questions about best practices.<br>
&gt;<br>
&gt; Let&#39;s say that there is a multithreaded application called X in which<br>
&gt; many threads needs to make client calls to the netty server.<br>
&gt;<br>
&gt; And we are using protocol buffers nio with netty.<br>
&gt;<br>
&gt; FIRST QUESTION<br>
&gt;<br>
&gt; In application X, how many clients should it use?<br>
&gt;<br>
&gt; a) ONE client<br>
&gt; 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>
&gt; SECOND QUESTION<br>
&gt;<br>
&gt; In the example,<br>
&gt;<br>
&gt; <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>

&gt;<br>
&gt; Would this be an inefficient implementation of a handler considering<br>
&gt; that it will block at line 71 ?<br>
<br>
</div>Handler itself does not call that method at all.  It&#39;s the main thread<br>
that calls it.  Therefore, I wouldn&#39;t say it&#39;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>