如何为Java应用程序创建简单的分布式Map?

如何为Java应用程序创建简单的分布式Map?

问题描述:

我正在寻找一个Map来在不同机器上运行的两个Java Web应用程序实例之间共享信息。读取和写入此映射需要非常快,并且不必是事务性的,即如果一个实例有一段时间的陈旧数据就可以了。

I am looking for a Map to share information between two instances of a Java web application running on separate machines. Reads and writes to this map need to be very fast and don't have to be transactional i.e. its ok if one instance has stale data for a while.

任何建议?

我需要跟踪用户上次在应用程序中执行某些操作的情况,因此如果此信息已过期,则非常糟糕。速度和易用性很重要。我不希望写入Map以影响响应时间。

I need to keep track of the last time a user did something in the application, so its not terribly bad if this information is out of date. Speed and ease of use are important. I don't want writes to the Map to impact response times.

我会尝试Hazelcast,JGroups或Ehcache。所有都支持分布式映射。

I would try Hazelcast, JGroups or Ehcache. All support a distributed map.

编辑:另一种选择是使用RMI top在一个或另一个JVM中运行的服务。这样就不需要额外的库了。

Another option is to use RMI top a service running in one or the other JVM. This avoids the need for an additional library.