0

I have two Java applications running on the same machine. As there was a requirement for remote connection we implemented the inter-jvm communication via http. We are passing about 10MByte imagedata 100 times a second from one vm to the other. With http we got huge delays as the write-function took too much time. As speed is the most important criteria, http can be skipped as requirement. Then we tried sockets, but it's still too slow. I've read about RMI and Chronicle (openhft) for fast inter-jvm messaging. Chonicle sounds interesting to me as we could use chronicle-queues for message passing and chronicle-map for sharing the image data.

But to be honest, I cannot estimate what would be best. The use case is the following: The server collects images. Clients requests a list of available images. As soon as the client gets the message, the clients requests one specific image. The server has the image already loaded, and needs to send the image to the client. Any suggestions what strategy to use? We could also send all images to the client, but this would cause the server to use too much time sending data, which is not needed.

Thanks for your tips.

leventov
  • 14,760
  • 11
  • 69
  • 98
blaster
  • 845
  • 1
  • 10
  • 25

2 Answers2

2

You can simply keep the images data in files on a tmpfs/shmem filesystem via memory-mapped buffers. Then you only have to notify the other process of the file name it has to access, e.g. via a persistent TCP connection.

the8472
  • 40,999
  • 5
  • 70
  • 122
0

Chronicle Map and Queue are designed for low latency storage. In this context the IPC is at least 50x faster, however for really big messages low latency is not the issue but throughput/bandwidth.

If you are on a local machine you should be able to write 2 GB/s to 4 GB/s over loopback TCP. This translates to 200 - 400 x 10 MB images per second.

If you have 10 Gig-E network connection, you should be able to send around 100 x 10 MB each second but that will use the entire network.

If you only have a 1 Gb/s network connection you are limited by the bandwidth you have to at most 100 MB/s or 10 x 10 MB each second.

One way around this problem is to run both the application which produces the image and the application which needs the image in the same JVM. This way you don't need to worry about TCP or IPC at all.

Peter Lawrey
  • 525,659
  • 79
  • 751
  • 1,130