SoftMemes
SoftMemes

Reputation: 5702

Using Oracle Coherence, how expensive is it to create a new NamedCache?

In a project where we expect to have a large number of concurrent users, we have a choice of either using a named cache per connected user (session), or one big named cache for all session state. Using one big cache would be more complex, as we want a flexibly mechanism for attaching data to a session, but might be more performant. The main reason for using a unique named cache per session would be the simplicity of being able to destroy all data related to it by simply destroying the named cache. This is expected to run in memory only and the access rate will be very low.

How much more performant would it be to use one big cache? Is it considered "bad practice" to use a large number of named cache instances using Coherence? In short, how much of an overhead is it to allocate a new named cache in Coherence?

Upvotes: 1

Views: 871

Answers (2)

Patrick Peralta
Patrick Peralta

Reputation: 176

In general, the largest overhead associated with NamedCaches is the creation of an MBean to track its statistics. Replication of these MBeans may consume more network bandwidth than desirable. It will also be unwieldy to open up JConsole to see hundreds or thousands of cache MBeans.

If your requirement is to use multiple cache entries to store data related to a user, I would implement this using key association. Using this approach, you can create a composite key that contains the user identity along with an identifier for the cache entry. This approach will force all data for a particular user to reside on the same partition - and thus the same storage member.

You can then use this to target filters and entry processors to the associated key - including entry processors to remove the cache entries when the user's session expires. This will be far more efficient as it will require only one cache server to respond to requests for a user, instead of requiring the entire cluster to respond to a request to destroy a cache.

These links should get you started:

http://docs.oracle.com/cd/E24290_01/coh.371/e22837/api_dataaffinity.htm

http://blackbeanbag.net/wp/2010/06/06/coherence-key-howto/

Upvotes: 2

Kumar225
Kumar225

Reputation: 227

Why not use CoherenceWeb

CoherenceWeb is exactly for this purpose, it is used to maintain a user/member's session data.

In CoherenceWeb it uses one cache to maintain session data for all users, with one entry for each member.

Upvotes: 0

Related Questions