简体   繁体   English

在同一台物理计算机上连接两个Java进程的最快方法是什么?

[英]What is the fastest way to connect two Java processes on the same physical machine?

I have a large in-memory cache inside my Java application, which is being filled after application starts. 我的Java应用程序内部有一个很大的内存缓存,在应用程序启动后将被填充。 It's makes redeployments extremelly expensive and slowers development process. 这使得重新部署极其昂贵,并且减缓了开发过程。

To solve the problem I'd like to outsource the cache to a separate Java process. 为了解决该问题,我想将缓存外包给一个单独的Java进程。 What is the fastest way to connect two Java processes on Linux? 在Linux上连接两个Java进程的最快方法是什么?

As a fastest solution I'd recommend you to use Hazelcast . 作为最快的解决方案,我建议您使用Hazelcast They support distributed maps. 它们支持分布式地图。 You can define simple, 2 nodes cluster, so when both your processes are up the date will be shared, when one of them is going down the data will be still in the memory of dedicated process, when the main process is up again the data will be shared again. 您可以定义2个节点的简单集群,因此当两个进程都启动时,将共享日期,当其中一个进程关闭时,数据仍将保留在专用进程的内存中,而当主进程再次启动时,数据将共享将再次共享。

The only thing that you have to change in your code is the line where you create instance of your map. 您唯一需要更改的代码就是创建地图实例的行。 You have to use the Hazelcast API instead of new HashMap<>() . 您必须使用Hazelcast API而不是new HashMap<>()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM