java 轻量级低延迟的Java网络库?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11158543/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-31 04:00:59  来源:igfitidea点击:

Lightweight and low-latency Java network library?

javanetworkingnionetty

提问by user1128016

I'm working on a client-server pair where the multithreaded client performs thousands invocations of the server per second and the first priority is to achieve a minimal latency. Throughput should be high as well. Both client and server are written in Java, communication semantics is quite simple (put/get operations).

我正在处理客户端-服务器对,其中多线程客户端每秒执行数千次服务器调用,首要任务是实现最小延迟。吞吐量也应该很高。客户端和服务器都是用 Java 编写的,通信语义非常简单(put/get 操作)。

What is the best Java network library/framework for these requirements? Servers like Tomacat/Jetty seems to be heavyweight. I'm thinking about MINA or Netty, but I'm not sure that these asynchronous libs will provide a stable low latency under heavy workload.

满足这些要求的最佳 Java 网络库/框架是什么?像 Tomacat/Jetty 这样的服务器似乎是重量级的。我正在考虑 MINA 或 Netty,但我不确定这些异步库是否会在繁重的工作负载下提供稳定的低延迟。

回答by Sergii Zagriichuk

I suggest you to try kryonetframework.

我建议您尝试使用kryonet框架。

回答by Peter Lawrey

If you want to communicate on the same machine you can try something like Java Chroniclewhich can support over a million persisted messages per second with sub-microsecond round trip times.

如果你想在同一台机器上通信,你可以尝试像Java Chronicle这样的东西,它可以支持每秒超过一百万的持久化消息,往返时间为亚微秒。

If you want low latency between machines, you need to look very carefully at your hardware. For commodity hardware your round trip latency will be 100 micro-seconds per more. With specialist hardware you are looking closer to 20 micro-seconds.

如果您想要机器之间的低延迟,您需要非常仔细地查看您的硬件。对于商品硬件,您的往返延迟将是每多 100 微秒。使用专业硬件,您可以看到接近 20 微秒的时间。

Or you could communicate on the same box and get much lower latencies. ;)

或者您可以在同一个盒子上进行通信并获得更低的延迟。;)

回答by pcdv

You can also try Jocket. It shares some concepts with Java Chronicle but is directly targeted at replacing the standard Socket implementation.

你也可以试试夹克。它与 Java Chronicle 共享一些概念,但直接针对替换标准 Socket 实现。

RTT latency is below the microsecond for a ping-pong between processes.

对于进程之间的乒乓,RTT 延迟低于微秒。

回答by ControlAltDel

If you need ultra-high performance and throughput, I recommend using raw sockets (check out Socket and ServerSocket - there may be an nio version too). This will free you from the overhead contained in HTTP and other protocols

如果您需要超高性能和吞吐量,我建议使用原始套接字(查看 Socket 和 ServerSocket - 可能也有 nio 版本)。这将使您免于包含在 HTTP 和其他协议中的开销