Netty性能
在具有数万个连接的应用程序中使用 Netty 和不使用 Netty 时,性能有什么真正的区别吗?
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 connections?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
事实并非如此,使用 Netty 的一个很好的理由是提高连接的可靠性,让您对连接的功能进行编码,而不用担心可能出错的所有细节。 (通常只有通过艰难的方式才能找到)
Netty 可以帮助您扩展超过 1K 的连接。但是,如果您不需要这么多连接,您可能会发现简单的代码性能最佳。
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.
正如彼得指出的那样,事实并非如此。
然而,我发现 Netty 还提供了一个非常好的 API 来构建服务器。尽管 API 有一点学习曲线,但它制作精良,并且创建新服务器可能很简单。它在代码方面也非常高效,因此,如果您有一个简单的协议和实现,那么您将需要很少的代码。
仅当您正在为 HTTP 之外的其他内容构建服务器时,才会出现这种情况。如果您正在谈论 HTTP Web 应用程序,请选择“尝试过”为 true。 Apache 用于直接 HTML 页面,Tomcat 如果您需要 Servlet。
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 应用程序不一定要转到 apache httpd 和 tomcat:
HTTP web app is not necessarily go to apache httpd and tomcat:
Netty 非常快,尤其是在连接很多的情况下。
根据我的经验:
Netty is very fast, especially with many connections.
In my experience:
Twitter 在其搜索系统中使用了 Netty:
参考:Twitter 搜索速度现在快了 3 倍< /a>
Twitter used Netty in its Search System:
Ref: Twitter Search is Now 3x Faster
实际使用Tomcat NIO,最多可以获得16000个并发连接;请注意,这是一台机器上的并发连接。这是与 Jetty 进行比较的测试,当他们不断给予它们越来越多的内存时,Jetty 的最高值达到 4000。 (http://www.javalobby.org/java/forums/t92965.html)
并且使用“约定优于配置”框架(例如具有内置 REST 功能的 Grails)(或简单的插件(例如 RestRPC)),您可以在几秒钟内轻松构建 API、Webhooks 等。
我还可以使用 Spring Security 插件更好地控制谁可以通过什么 IP 或什么角色访问什么 api 调用(如果我愿意)。
Netty 的局限性在于,过多的 Grails 插件可以远远超出使用 Tomcat NIO 的范围。
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.