简体   繁体   English

加载并保留Hazelcast分布式地图

[英]Loading and persisting Hazelcast distributed map

I am using Hazelcast(3.8.1) as a cache service in my application. 我在应用程序中使用Hazelcast(3.8.1)作为缓存服务。 After going through the hazelcast documentation , I have few doubts related to it: 阅读完hazelcast文档后 ,我对此几乎没有疑问:

  1. If we use Write-Behind Persistence , this being an async calls to its local queue, from which eventually we persist it to a db. 如果我们使用Write-Behind Persistence ,则这是对其本地队列的异步调用,最终我们将从该队列将其持久化到数据库。 My question is, if all the nodes go down, then will there be a data loss in this scenario? 我的问题是,如果所有节点都掉线,那么在这种情况下会不会有数据丢失?

Note: I understand that one copy of the queue is also being maintained in a back up node. 注意:我了解队列的一个副本也在备份节点中维护。 But my scenario is when all the node goes down, can we lose data? 但是我的情况是,当所有节点都关闭时,我们会丢失数据吗?

  1. Does hazelcast maintain an offline persistence when it goes down and load it when it is started [for all the nodes]? hazelcast在关闭时是否保持脱机持久性并在启动时(对于所有节点)加载脱机持久性?

Appreciate responses. 感激之情。

The answer to 1 is obvious, and is applicable to any in-memory system with asynchronous writes. 1的答案是显而易见的,并且适用于任何具有异步写入功能的内存系统。 If all nodes in your cluster go down, then yes, there's potential for data loss as your system is only eventually consistent. 如果群集中的所有节点都出现故障,那么是的,由于您的系统最终才是一致的,因此有可能丢失数据。

For question 2 : Hazelcast is an in-memory cache and therein lie its primary benefits. 对于问题2 :Hazelcast是一个内存缓存,它的主要好处就在其中。 Writing to or loading from persistent storage should be secondary because it conflicts with some of the main attributes of a caching system (speed, I guess...). 向持久性存储写入或从持久性存储中加载应该是次要的,因为它与缓存系统的某些主要属性(速度,我想...)相冲突。

With that said, it allows you to load from and write to persistent storage , either synchronously (write-through) or asynchronously (write-behind) 话虽如此,它允许您同步(直写)或异步(后写) 从持久性存储加载和写入持久性存储

If your main reason for using Hazelcast is replication and partitioning (of persistent, consistent data), then you'd be better off using a NoSql database such as Mongodb. 如果使用Hazelcast的主要原因是复制和分区(持久,一致的数据),那么最好使用NoSql数据库(例如Mongodb)。 This depends a lot on your usage patters because it may still make sense if you expect far more reads than writes. 这在很大程度上取决于您的使用情况,因为如果您期望读取比写入更多,这仍然有意义。

If, on the other hand, your main reason for using it is speed, then what you need is to better manage fault-tolerance, which has more to do with your cluster topology (maybe you should have cross-datacenter replication) than with persistence. 另一方面,如果您使用它的主要原因是速度,那么您需要的是更好地管理容错能力,这与集群拓扑(也许应该具有跨数据中心复制)更多的是持久性无关。 。 It's atypical to be concerned with "all nodes dying" in your DC unless you have strong consistency or transaction requirements. 除非您有很强的一致性或交易要求,否则通常不关心DC中的“所有节点都死了”。

Yes, you would lose the data in memory if it is not persisted to the database yet. 是的,如果尚未将数据持久保存到数据库中,则会丢失数据。

OTOH, Hazelcast has Hot Restart for persistence to disk in Enterprise version. OTOH,Hazelcast具有热重新启动功能 ,可持久保留企业版中的磁盘。 This helps in case of a planned shutdown of whole cluster or a sudden cluster-wide crash, eg, power outage. 这在计划关闭整个群集或突然发生群集范围内的崩溃(例如断电)的情况下有帮助。

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

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