24

我们的前端是简单的 Jetty(以后可能会被 Tomcat 取代)服务器。通过 servlet,我们提供了一个公共 HTTP API(或多或少 RESTful)来公开我们的产品功能。

在后端,我们有一个 Java 进程,它执行多种维护任务。虽然后端进程通常会在适当的时候执行自己的任务,但有时,前端需要唤醒后端以在后台执行某个任务。

哪个 (N)IO 库最适合这项任务?我找到了 Netty、Grizzly、kryonet 和普通的 RMI。现在,我倾向于说 Netty,它看起来使用起来很简单,而且可能非常可靠。

你们中有人有这种设置的经验吗?你的选择是什么?

谢谢!

4

4 回答 4

18

尝试翻译此文档以回答您的问题。 http://blog.xebia.fr/2011/11/09/java-nio-et-framework-web-haute-performance/

该协会作为法国著名的 Java EE 专家,在 VmWare(USI2011)赞助的法国挑战赛的背景下,做了很多 NIO 服务器的 poc。它是关于构建一个简单的测验应用程序,可以处理 100 万连接用户的负载。

他们以出色的成绩赢得了挑战。他们的实现是 Netty + Gemfire,他们只是用 MemoryAwareThreadPool 替换了 CachedThreadPool。

Netty seems to offer great performances, and is well documented.

They also considered Deft, inspired by Tornado (python/facebook) but it's still a bit immature for them

Edit: here's the translated link provided in the comments

于 2011-11-25T13:31:55.623 回答
4

My preference is Netty. It's simple yet flexible. Very fast and the community around Netty is awesome.

于 2011-11-26T17:14:28.500 回答
3

The company I work for is currently evaluating CoralReactor. It is a commercial software but it has the easiest API I have ever seen for Java NIO. My personal opinion is that Netty makes things too complicated, especially if you want to go garbage-free and single-threaded, which are a requirement for many companies from the finance, advertisement and game industry.

于 2015-07-07T05:37:01.603 回答
2

我将通过使用 JMS 将它们解耦,只需让您的后端坐在那里侦听一些(一组)控制队列,您就完成了。无需在这里编写自定义的 nio api。

一个示例提供者是 hornetq。这也可以作为进程中的 jms 代理运行,它在后台使用 Netty。

于 2011-11-25T12:56:09.723 回答