Ehcache / Hibernate and RMI replication with large number of entities

故事扮演 提交于 2019-12-09 16:26:40

问题


I'm currently investigating how to use the RMI distribution option in ehcache. I've configured properly ehcache.xml and replication seems to work fine. However I've 2 questions:

-> It seems ehcache/ hibernate creates 1 cache per Entity. This is fine, however when replication is in place it create 1 thread / cache to replicate. Is this the intended behavious ? As our domain is big, it creates about 300 threads, which seems to me really big

-> Another nasty consequence is that the heartbeat messagre seems to aggregate all of those cache names. From what I saw the message should fit in 1500 bytes, which it does not, which leads to this message in my logs: Heartbeat is not working. Configure fewer caches for replication. Size is 1747 but should be no greater than1500. Any idea on how this could be changed ?

Thanks a lot for your help


回答1:


We already have one hack where we have our own custom copy of the hibernate EhCacheProvider that overrides buildCache() to create our own Cache objects with shortened names (the hash of the name). This gets around the 1500 limit. We keep a hashmap of the original names with the hash names for reverse lookup.

We did this a while ago and have been using it in production.

We also looked at your other issue to have a single replicator thread. First we copied RMICacheReplicatorFactory and changed createCacheEventListener() to return our copy of RMIAsynchronousCacheReplicator that we modified by making the replicationThread field static and then making the necassary fixes for that. We didn't get around to testing it thoroughly or putting it in production, but are looking at it again which is how I found this post :)




回答2:


Did you consider JBossCache as an alternative to EHcache? JBossCache has distributed transactions and is well-tested for high-loads. It has lower-level replication mechanisms which can allow you to use UDP or TCP multicasting/broadcasting replication.




回答3:


Did you consider EHCache over Terracotta? Take a look at Terracotta Hibernate Integration and Terracotta EHCache Integration

Importantly the Terracotta distributed EHCache is coherent - all nodes have the same view of the cache. This is very important for one of the applications I worked with.

Take a look. It works like a charm for us.

/RS




回答4:


By the way, the 1500 byte limit has been addressed for the Ehcache 1.7.1 release of ehcache-core. See EHC-424.




回答5:


Is jms replication an option?

(I have been looking in to using it with async behavior, it works nice. Documentation was wrong so I had to check the source code to see the actual attributes needed to configure it properly. Good thing with jms is that if you have that infrastructure set up you don't have to configure any firewalls and so on to let it through.)



来源:https://stackoverflow.com/questions/566264/ehcache-hibernate-and-rmi-replication-with-large-number-of-entities

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!