General J2EE: Cache on an app server cluster
Here is the scenario:
- Posted by: arihant jain
- Posted on: November 08 2003 20:47 EST
A cache of about 70 MB has to be implemented. It is only updated once in a day and read very frequently. What would be the best strategy to implement it for many weblogic servers in a cluster. Yes, the state of the cache should be identical across the cluster.
I know of two options.
1. Each server loads up the cache from the database and the cache is saved in memory as a normal hashmap object.
2. Use session bean to implement cache.
I would appreciate if someone could point the pros and cons of the second approach.
There is not much point in implementing your cache as a session bean. The main reasons to use a session are:
a) Need to access information remotely.
b) Need to make operations transactional.
Neither of these are relevant for local caches. I would go with option (1) (a simple in memory cache with a HashMap).
There is a third option, Tangosol's Coherence. Coherence's Replicated cache seems to be exactly what you are looking for. Using the cluster-wide locking mechanism you can maintain concurrency (i.e. state) across the cluster.
Tangosol Coherence: Cluster your Work. Work your Cluster.