开发者

Netty performance

Is there any real difference to the performance when you use Netty and if you don't use it in an application with tens of thousand of connect开发者_JS百科ions?


Not really, a good reason to use Netty is to improve the reliability of the connections and leave you to code what the connection does rather than worry about the details of everything which can go wrong. (Often only comes by finding out the hard way)

Netty may help you scale over 1K connections. However if you don't need so many connections you might find that simple code performs best.


Not really, as Peter noted.

However, I've found that Netty also offers a very nice API for building a server. Although there is a bit of a learning curve to the API, it's well made and creating a new server can be trivial. It's also quite efficient code-wise, so you would have very little code, if you have a simple protocol and implementation.

This is ONLY if you are building a server for something other than HTTP. If you are talking about an HTTP web application, go with the tried an true. Apache for straight HTML pages, Tomcat if you need Servlets.


HTTP web app is not necessarily go to apache httpd and tomcat:

  1. Check this and this to see how superior nginx is compare to apache httpd
  2. Click here to see How Play!framework (based on Netty) outperforms those based on Tomcat/Servlet


Netty is very fast, especially with many connections.

In my experience:

  • It's more scalable than the standard Java IO. In particular, the old synchronous Java IO packages require you to tie up one thread per connection. This can become problematic with tens of thousands of connections!
  • It's approximately the same speed as what you would get if you wrote custom networking code using Java NIO, but it's a lot simpler to just use Netty directly rather than go down this route.


Twitter used Netty in its Search System:

Ref: Twitter Search is Now 3x Faster


Actually using Tomcat NIO, you can get up to 16,000 concurrent connections; mind you thats CONCURRENT connections on one machine. This was tested against as a comparison vs Jetty which topped out at 4000 when they kept giving them more and more memory. (http://www.javalobby.org/java/forums/t92965.html)

And using a 'convention over config' framework like Grails with REST functionmality built in (or simple plugins like RestRPC), you can easily build API's, webhooks, etc in seconds.

I also have more control using Spring Security plugin as to who can access what api call via what IP or what role if I want.

Netty has limitations that the plethora of Grails plugins can expand far beyond using Tomcat NIO.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜