Telerik OpenAccess ORM maintains several cache levels that can be used in various application scenarios. While the L1 cache is specific for each object scope, the L2 cache works on higher level as it is common to all object scopes in an application. But what if we want to have the cache working even on higher level – to be shared between many applications?

The feature that has to be used in such scenarios is the L2 Cache Cluster. It provides the ability to synchronize the L2 caches of many applications that operate on the same database. To achieve this, each modifying transaction sends messages to all participants in the cluster, so they can evict the outdated data. This communication is done in an asynchronous fashion: There is a time-frame, in which one L2 cache could be evicted but another L2 cache could still hold old data. This time-frame depends on the cache cluster implementation chosen.

Currently the L2 cache cluster implementation uses MSMQ for transporting eviction messages. By default, the MSMQ Windows component is not installed, so you should install it on each machine that will use the L2 cache cluster. To install MSMQ on a Windows XP system, go to Control Panel -> Add or Remove Programs -> Add/Remove Windows Components and install Message Queuing. On Windows Vista this component can be installed by using Control Panel -> Programs and Features -> Turn Windows features on or off and enabling MSMQ-Multicasting Support.

Initially the protocol is limited by speed in order not to overload the slow links in WAN environments. However, for our purposes in a LAN, increasing the speed would higher the performance. To change the speed, edit the following registry key:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSMQ\Parameters\MulticastRateKbitsPerSec

The default value is 560 kb/s. We recommend setting a value of 0xffff. To limit the amount of memory MSMQ needs, the registry entry:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSMQ\Parameters\MessageCleanupInterval

must be set to a more reasonable value in milliseconds; the installed default is for 90 days. A recommended value is around 4000 milliseconds, as the default expiration for time-to-reach-queue is 2000 milliseconds.

Finally, to enable the usage of a L2 cache cluster, the following two entries should be added to the <backendconfiguration> node in the App.config file of each application:

<l2CacheClusterTransport>MSMQ</l2CacheClusterTransport>
<l2CacheClusterTransport.multicastaddr>224.1.1.1:666</l2CacheClusterTransport.multicastaddr>

 

Note that the L2 cache configuration nodes should be there as well. For full specification of the available settings for the L2 cache cluster, please refer to this document.

Enabling the L2 cache could really improve the performance of your application if it requires often reads from the database. Additionally, if you have different applications working with the same database, the L2 cache cluster will assist you to keep those caches in sync so the applications are not in a conflict but even help each other, something you might have not taken into account.


About the Author

Jan Blessenohl

Product Manager,
OpenAccess ORM Team

Comments

Comments are disabled in preview mode.