Thursday 14 February 2013

WebSphere Application Server - Dynamic Cache ( DynaCache ) in a Clustered Environment

For the IBM BPM project on which I'm currently engaged, we're looking at the use of DynaCache across a clustered WAS 8 environment.

Knowing a little about DC, I wanted to read up further, especially with regard to the cache's behaviour across a multi-node cluster.

Here's a few useful items: -


<snip>
Think of DynaCache as a sophisticated Java™ Hashtable.

The code used to provide the in-memory cache services extends the Java Dictionary class, which is the abstract parent of Hashtable. You configure DynaCache to store objects, and later, based on some data matching rules, DynaCache retrieves those objects and serves them from its cache. Caching rules are stored in a configuration file called cachespec.xml. Single or multiple caches are supported. Caches are stored in the JVM heap memory and DynaCache supports overflow to disk if enabled and when required.

The system administrator has some degree of control over what is placed in memory and what (if anything) overflows to disk via configuration settings. DynaCache also calls a least recently used (LRU) algorithm during the item selection process for memory-based item eviction or overflow. The LRU algorithm consults with a user-specified cache entry priority number before the evictee is chosen. Higher numbered items stay in memory longer.

Disk offload of cache entries from memory occurs when the memory cache fills up or when the server is in the process of performing a normal, administrator-directed shut down and the "FlushToDiskOnStop" property is enabled. Upon a server restart, requests for cache entries are fulfilled by reloading the saved disk data into memory.
</snip>



<snip>
So friends, here in one of my assignment we are using dynacache to share object across application.

I posted my query on IBM developer works asking for how DynaCache works in cluster environment and i got one reply, so just thought of sharing on my blog.

DynaCache behaviour in clustered environment is somewhat different and need to take special attention.

Fist, if you don't have data replication domain setup in cluster environment each node has its own copy of the dynacache and which may cause issues in case of fail over or in case when objects are shared between diff application.

To use the your dynacache as global object across the cluster , you need create one data replication domain for the all nodes in the cluster and enable the data replication service.

To enable data replication service of dynacache, please refer to 
Configuring cache replication article in infocenter
</snip>


<snip>
Use this task to improve performance by configuring the data replication service (DRS) to replicate data from the dynamic cache service across the consumers in a replication domain.
</snip>


<snip>
With replication, data is generated one time and copied or replicated to other servers in the cluster, saving time and resources. Caching in a cluster has additional concerns. In particular, the same data can be required and generated in multiple places. Also, the permission the resources need to generate the cached data can be restricted, preventing access to the data.

Cache replication deals with these concerns by generating the data one time and copying it to the other servers in the cluster. It also aids in cache consistency. Cache entries that are not needed are removed or replaced.
</snip>


<snip>
Use this task to configure a data replication domain to transfer data, objects, or events for session manager, dynamic cache, or stateful session beans. Data replication domains use the data replication service (DRS), which is an internal product component that performs replication services, including replicating data, objects, and events among application servers.
</snip>

Configuring DynaCache

The dynamic cache service consolidates caching activities to improve application performance. By caching the response from servlets, web services, Java(TM) Server Pages (JSP) files, and WebSphere(R) Application Server commands, the application server does  not have to perform the same computations and back-end queries multiple times.

Create the Replication Domain

Via the WAS Integrated Solutions Console (ISC), navigate to Environment > Replication domains )

Configure Dynacache

Via the WAS Integrated Solutions Console (ISC), navigate to Application servers > PCSR011.AppTarget ( your server name goes here ) > Dynamic cache service.



*UPDATE* I neglected to mention an excellent article on DynaCache, written by a former colleague of mine, Gab Telerman,  that's also worth a read: -

Using DynaCache to improve the performance of your WebSphere Process Server or WebSphere ESB solution

In addition, Gab also recommended that I take a look at the jsCache toolkit on IBM Blueworks ....

5 comments:

Unknown said...

Hi Dave, during this project did you look into analysing how much JVM heap is used by DynaCache?. I'm using IBM Heap analyser currently and I'm seeing several java.util.HashMap entries which I think are sections of heap allocated to Dynacache, however I would like to confirm this with someone who has carried out similar work.

Bob

Dave Hay said...

Hi Bob, good to hear from you, it's been WAY too long.

Yes, I'd guess that what you're seeing in the heap IS related to the use of DynaCache.

Cheers, Dave

Harshad said...
This comment has been removed by the author.
Harshad said...

Hi Dave,

Do you know what will happen in the below scenario if DynaCache is configured as a global object accross the cluster:
1 node updates a portion the cache. Does this block read access for the other 5 at that time? If so, is it synchronized on the cache as a whole or individual objects?

Harshad.

Dave Hay said...

@Harshad, off the top of my head, I do not know, I'm afraid. Cheers, Dave

Visual Studio Code - Wow 🙀

Why did I not know that I can merely hit [cmd] [p]  to bring up a search box allowing me to search my project e.g. a repo cloned from GitHub...