To use or not to use netty?

"Trustin Lee (이희승)" trustin at gmail.com
Fri Jan 8 18:40:53 EST 2010


Since there was no reply, let me step in.

Enno Shioji wrote:
> Hi,
> 
> To put it in a nut shell, my questions is "When is it appropriate to use
> netty instead of containers such as tomcat, jetty etc.?"
> 
> 
> Well, let me explain my situation..
> 
> I have an app. that accepts tasks from clients (other servers), chops it up
> to smaller subtasks, dispatches them to a group of servers, receive the
> calculated results from these servers, aggregate the result and sends a HTTP
> callback to the original client. 1 instance of our app will manage several
> hundred worker servers, between which several hundred transactions / second
> will be taking place.

I see.  Data mediation server is similar to a proxy server in terms of
the actual implementation.  If all operations (i.e. talking to the
servers that actually do the subtask) are done asynchronously (perhaps
using Netty here, too), you could handle all requests with very small
number of threads.  So, I'd say Netty fits very well for this use case.
 Check out Dave's testimonial in the web site.

> This app. used to use a JEE container to accept connections and apache
> HTTPClient to send data. However, in order to deal with scalability issues,
> we decided to move out from the JEE container.

JEE containers are basically same with Tomcat and other Web application
servers if you do not use more advanced features like EJB.  I don't
think switching from a JEE container to Tomcat will improve scalability.

> So, I was considering web containers such as Tomcat, Jetty etc. but then I
> stumbled on netty. Personally I'm inclined to use netty, because of the
> freedom I think it will give us. For example, in our current system,
> servants (worker severs that do the calculation) periodically poll our app.,
> but we could change it to a comet like protocol or to a push-model.
> 
> However, the problem is that we have no experience with network application
> framework such as netty, or any event-driven network programming for that
> matter. Also, although performance is important for us, it is unlikely that
> our app will serve more than e.g. 2000 concurrent connections (that is,
> unless we change to a comet style protocol). I also assume it will be more
> to code if we choose netty vs. e.g. a servlet container.

Yes.  At the cost of longer code, you get full control over HTTP
connection and better performance for your use case (data mediation).

> I guess nobody can give a definitive answer to such a question, as it just
> depends on my particular situation, but I wanted to know if there are
> anybody who had to make similar decisions, and if so, I wanted to know what
> their experience was like.
> 
> Also, just in general, when do you think it makes sense to use netty? Or
> perhaps more importantly, when does it NOT make sense to use netty?

If you are writing an ordinary web application with UI on a browser,
using Netty directly is not a good idea obviously.

However, if someone writes a servlet adaptor on top of Netty HTTP, then
you could even run a web framework on top of Netty, which means you can
restart a web application faster than ever.  Just thinking out loud! :)

If you are writing a special purpose HTTP server that must support
massive concurrency, media streaming, proxying, long polling, ..., then
Netty is the way to go.

HTH,
Trustin

-- 
what we call human nature in actuality is human habit
http://gleamynode.net/


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 260 bytes
Desc: OpenPGP digital signature
Url : http://lists.jboss.org/pipermail/netty-users/attachments/20100109/75d43348/attachment.bin 


More information about the netty-users mailing list