[Building Sakai] Clustering a HashMap

Ian Boston ieb at tfd.co.uk
Mon Jan 17 10:00:21 PST 2011


On 14 Jan 2011, at 12:45, Adrian Fish wrote:

> At the moment I'm playing with creating an EhCacheFactory bean in my 
> spring config, using the MemoryService to create a Cache instance and 
> then putting the hashmaps in that if they are not already there.

IIRC ehCache replicates on element levels. So if you put a hashmap into a Cache as a single Cache element, then every time you modifiy the map it will replicate, which will soon kill your server with replication traffic.

Try and put the contents of the map at the lowest level in the map, then when you change one item, only that will be replicated.
Also think hard about if you really want replication, or just invalidation. In general relying on replication as a mechanism to distribute messages is soon going to overload a production system. I would look at things like node.js or cometD and communicate a chat end point to the each user with messages going to that destination rather than rely on a replicated, in memory structure to achieve this.

If you really must use replication and ehCache, then configure it with JGroups underneath as thats probably the most efficient transport if you servers are on the same subnet,

If you want an alternative, take a look at infinspan which does a better job of replication in larger clusters, and then there is memcached (but you will have to OS level things on install)

HTH
Ian




More information about the sakai-dev mailing list