Netty and Protocol Buffers.

Marco Villalobos mvillalobos at supplyframe.com
Tue Jun 21 19:12:58 EDT 2011


Thank you Trustin.

Yes, you are right as well ;)  It took a while, but I learned this through
trial, error, and learning.

This is what I've learned, and it took a while for me to wrap my head around
these concepts:

a)

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).
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
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.

In netty terms, I'll need a pool of netty clients that talk to my netty
server.

b)

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.


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.

-Marco

On Tue, Jun 21, 2011 at 2:45 AM, "이희승 (Trustin Lee)" <trustin at gmail.com>wrote:

> Marco Villalobos wrote:
> > I have a question on proper use of netty with protocol buffers.
> > I made extensive use of the LocalTime example in the documentation.
> >
> > And I have some questions about best practices.
> >
> > Let's say that there is a multithreaded application called X in which
> > many threads needs to make client calls to the netty server.
> >
> > And we are using protocol buffers nio with netty.
> >
> > FIRST QUESTION
> >
> > In application X, how many clients should it use?
> >
> > a) ONE client
> > b) A pool of clients?
>
> If there are not many instances of application X connecting to the
> server, you could keep a pool of clients to get better throughput by
> utilizing more cores of the server.  Otherwise, the server load will
> overweigh the throughput gain.
>
> > SECOND QUESTION
> >
> > In the example,
> >
> >
> http://docs.jboss.org/netty/3.2/xref/org/jboss/netty/example/localtime/LocalTimeClientHandler.html
> >
> > Would this be an inefficient implementation of a handler considering
> > that it will block at line 71 ?
>
> Handler itself does not call that method at all.  It's the main thread
> that calls it.  Therefore, I wouldn't say it's inefficient.  If you have
> to deal with multiple connections and requests, it will be inefficient
> and you will have to make it asynchronous.
>
> HTH
>
> --
> Trustin Lee, http://gleamynode.net/
>
> _______________________________________________
> netty-users mailing list
> netty-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/netty-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/netty-users/attachments/20110621/2161fe5b/attachment.html 


More information about the netty-users mailing list