Netty vs Apache MINA [英] Netty vs Apache MINA

查看:361
本文介绍了Netty vs Apache MINA的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

它们都提供大致相同的功能。我应该选择哪一个来开发我的高性能TCP服务器?什么是专业人士和缺点?

They both provide roughly the same functionality. Which one should I choose to develop my high-performance TCP server? What are the pros & cons?

参考链接:

Apache MINA 来源

Netty 来源

推荐答案

虽然MINA和Netty有着相似的野心,但它们却截然不同在实践中,你应该仔细考虑你的选择。我们很幸运,因为我们有很多MINA的经验,并且有时间和Netty一起玩。我们特别喜欢更干净的API和更好的文档。纸上的表现似乎也更好。更重要的是,我们知道Trustin Lee会随时回答我们的任何问题,他当然也是这样做的。

While MINA and Netty have similar ambitions, they are quite different in practice and you should consider your choice carefully. We were lucky in that we had lots of experience with MINA and had the time to play around with Netty. We especially liked the cleaner API and much better documentation. Performance seemed better on paper too. More importantly we knew that Trustin Lee would be on hand to answer any questions we had, and he certainly did that.

我们发现Netty的一切都比较容易。期。虽然我们试图重新实现我们已经在MINA上使用的相同功能,但我们从头开始这样做。通过遵循优秀的文档和示例,我们在更多,更少的代码中获得了更多功能。

We found everything easier in Netty. Period. While we were trying to reimplement the same functionality we already had on MINA, we did so from scratch. By following the excellent documentation and examples we ended up with more functionality in much, much less code.

Netty Pipeline对我们来说效果更好。它在某种程度上比MINA更简单,其中一切都是处理程序,由您来决定是处理上游事件,下游事件,还是消耗更多低级别的东西。 重放解码器中的吞噬字节几乎是一种乐趣。能够如此轻松地即时重新配置管道也是非常好的。

The Netty Pipeline worked better for us. It is somehow simpler than MINAs, where everything is a handler and it is up to you to decide whether to handle upstream events, downstream events, both or consume more low-level stuff. Gobbling bytes in "replaying" decoders was almost a pleasure. It was also very nice to be able to reconfigure the pipeline on-the-fly so easily.

但是Netty的明星吸引力是创建管道的能力处理程序的覆盖范围为。您可能已经在文档中已经阅读过这个coverage注释,但实质上它只是在一行代码中为您提供状态。没有混乱,没有会话映射,同步和类似的东西,我们只是能够声明常规变量(比如用户名)并使用它们。

But the star attraction of Netty, imho, is the ability to create pipeline handlers with a "coverage of one". You've probably read about this coverage annotation already in the documentation, but essentially it gives you state in a single line of code. With no messing around, no session maps, synchronization and stuff like that, we were simply able to declare regular variables (say, "username") and use them.

但是然后我们遇到了障碍。我们已经在MINA下有一个多协议服务器,我们的应用程序协议通过TCP / IP,HTTP和UDP运行。当我们切换到Netty时,我们在几分钟内就将SSL和HTTPS添加到列表中!到目前为止这么好,但是当谈到UDP时,我们意识到我们已经滑倒了。 MINA对我们非常好,因为我们可以将UDP视为连接协议。在Netty下,没有这样的抽象。 UDP是无连接的,Netty会这样对待它。 Netty在比MINA更低的级别上暴露了UDP的更多无连接特性。在Netty下你可以使用UDP做的事情比你在MINA提供的更高级别的抽象中所做的更多,但我们依赖它。

But then we hit a roadblock. We already had a multi-protocol server under MINA, in which our application protocol ran over TCP/IP, HTTP and UDP. When we switched to Netty we added SSL and HTTPS to the list in a matter of minutes! So far so good, but when it came to UDP we realised that we had slipped up. MINA was very nice to us in that we could treat UDP as a "connected" protocol. Under Netty there is no such abstraction. UDP is connectionless and Netty treats it as such. Netty exposes more of the connectionless nature of UDP at a lower level than MINA does. There are things you can do with UDP under Netty than you can't under the higher-level abstraction that MINA provides, but on which we relied.

事实并非如此简单地添加连接UDP包装器或其他东西。考虑到时间限制和Trustin的建议,最好的方法是在Netty实施我们自己的运输提供商,这不会很快,我们最终不得不放弃Netty。

It is not so simple to add a "connected UDP" wrapper or something. Given time constraints and on Trustin's advice that the best way to proceed was to implement our own transport provider in Netty, which would not be quick, we had to abandon Netty in the end.

因此,请仔细研究它们之间的差异,然后快速进入可以测试任何棘手功能的阶段,并按预期工作。如果你对Netty的工作表示满意,那么我会毫不犹豫地通过MINA。如果您从MINA迁移到Netty,那么同样适用,但值得注意的是,两个API确实存在显着差异,您应该考虑对Netty进行虚拟重写 - 您不会后悔!

So, look hard at the differences between them and quickly get to a stage where you can test any tricky functionality is working as expected. If you're satisfied that Netty will do the job, then I wouldn't hesitate to go with it over MINA. If you're moving from MINA to Netty then the same applies, but it is worth noting that the two APIs really are significantly different and you should consider a virtual rewrite for Netty - you won't regret it!

这篇关于Netty vs Apache MINA的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆