The fastest connection between JVMs with the same machine

I need to call a method from another JVM running on the same computer. These methods need to be called so many times with Java / native-like performance. This is a small output method with a small input signal. Another JVM runs on the same machine.

What is the fastest way to make this call and get the result from this other nearby JVM?

Some parameters are probably RMI, channels, sockets, JMS, optimized support for communication between the JVM with the same computer, some low-level hackers in the JVM. Any idea is welcome, no matter how specialized it is.

+4
source share
2 answers

The fastest way to communicate between JVMs on the same computer is to use shared memory, for example. through memory mapped files. This is 100 times faster than using Socket over loopback. for example, 200 ns round-trip time versus 10-20 microsecond transit times for sockets.

One implementation of the Java Chronicle BTW 100 ns latency includes message persistence.

If you need any of these solutions, you should not take it for granted. Often, when people say that they should have the “fastest”, they really mean that they don’t know how fast it should be so if they choose the fastest, it should be the right decision. This is usually not the case, because making the fastest decision often means that the trade-offs in design and implementation that it can turn are never needed, unless you knew what the requirements really were.

In short, if you don't have specific measurable latency and / or bandwidth requirements, you should assume that the simplest solution is what you really want. It can be replaced with something faster if it turns out that it is not suitable when you better understand what is required.

+5
source

Another option is 0MQ (ZeroMQ) , although it depends on what you mean by “fastest” - zeromq is great for bandwidth, but if you absolutely must have the minimum possible delay, that may not be optimal.

ZeroMQ can only be full for two JVMs, but it has the advantage that if you later want to transfer one of the JVMs to another machine or communicate with non-Java processes, ZeroMQ will still work fine - and it will scale to larger, more complex communications.

+1
source

Source: https://habr.com/ru/post/1447338/


All Articles