3 Replies Latest reply on Aug 21, 2009 5:02 AM by Manik Surtani

    How to desing cache in Client/Server mode?

    steeven steeven Newbie

      I'm working with an application in c/s mode, here is the requirements:
      Client: N clients, read-only cache, load data from cluster or server db
      Server: 1 or 2 serves, lazy-load cache from db, remove-node.

      It was said that the server update and share the cache data, and the client read-share cache from server. The server side loader was responsible to load data from db. the db is clustered.

      2 issues i met here:
      1: the 2 server cache both response on client cache query even singletonStore is enabled. because they are query the same clustered db, is it possible to restrict only the active loader response to read access?
      2: the client won't read data from server loader if the client is not configured as a buddy member.


      ==================================
      Server configuration:

      <?xml version="1.0" encoding="UTF-8"?>
      <jbosscache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns="urn:jboss:jbosscache-core:config:3.1">
      
       <transaction
       transactionManagerLookupClass="org.jboss.cache.transaction.GenericTransactionManagerLookup" />
      
       <eviction wakeUpInterval="5000">
       <default algorithmClass="org.jboss.cache.eviction.LRUAlgorithm" eventQueueSize="200000">
       <property name="maxNodes" value="5000" />
       <property name="timeToLive" value="1000000" />
       </default>
       </eviction>
      
       <clustering mode="i" clusterName="JBossCache-Cluster">
       <buddy enabled="true" poolName="myBuddyPoolReplicationGroup" communicationTimeout="2000">
       <dataGravitation auto="true" removeOnFind="false" searchBackupTrees="false"/>
       <locator class="org.jboss.cache.buddyreplication.NextMemberBuddyLocator">
       <properties>
       numBuddies = 1
       ignoreColocatedBuddies = true
       </properties>
       </locator>
       </buddy>
       <jgroupsConfig configFile="udp.xml" />
       </clustering>
      
       <loaders passivation="false" shared="true">
       <loader class="org.steeven.MyCacheLoader"
       async="false" fetchPersistentState="false" ignoreModifications="true"
       purgeOnStartup="false">
       <properties />
       </loader>
       </loaders>
      </jbosscache>
      



      Client configuration:
      <?xml version="1.0" encoding="UTF-8"?>
      <jbosscache xmlns="urn:jboss:jbosscache-core:config:3.0">
       <eviction wakeUpInterval="5000">
       <default algorithmClass="org.jboss.cache.eviction.LRUAlgorithm"
       eventQueueSize="200000">
       <property name="maxNodes" value="5000" />
       <property name="timeToLive" value="1000000" />
       </default>
       </eviction>
      
       <clustering mode="i" clusterName="JBossCache-Cluster">
       <buddy enabled="true" poolName="myBuddyPoolReplicationGroup"
       communicationTimeout="2000">
       <dataGravitation auto="true" removeOnFind="false"
       searchBackupTrees="false" />
       <locator class="org.jboss.cache.buddyreplication.NextMemberBuddyLocator">
       <properties>
       numBuddies = 1
       ignoreColocatedBuddies = true
       </properties>
       </locator>
       </buddy>
       <jgroupsConfig configFile="udp.xml" />
       </clustering>
       <loaders passivation="false" shared="false">
       <loader class="org.jboss.cache.loader.ClusteredCacheLoader"
       async="false" fetchPersistentState="false" ignoreModifications="false">
       <properties>
       timeout=500
       </properties>
       </loader>
       </loaders>
      </jbosscache>



        • 1. Re: How to desing cache in Client/Server mode?
          Manik Surtani Master

          1) don't use buddy replication for the server nodes. Since there are only 2, you don't need BR.

          2) don't even bother with REPL. Use INVAL since they are backed by the DB. This will reduce chattiness and traffic between the server nodes.

          3) You don't need singletonStore for the server nodes. You should allow both nodes to write to the DB if you are using INVAL. Only use singletonStore if you are using REPL.

          • 2. Re: How to desing cache in Client/Server mode?
            steeven steeven Newbie

            manik, thanks very much. Inval-async mode worked now.

            I think it is not possible to make only one server response read request, right? if one server failed to response, the other server could response at once. but at most case, both the server loader will response read request.

            another question, how to make the server readonly? the server will accept changes from client side. it is dangerous for my case.

            ===================================
            client:

            <?xml version="1.0" encoding="UTF-8"?>
            <jbosscache xmlns="urn:jboss:jbosscache-core:config:3.0">
            
             <eviction wakeUpInterval="5000">
             <default algorithmClass="org.jboss.cache.eviction.LRUAlgorithm"
             eventQueueSize="200000">
             <property name="maxNodes" value="5000" />
             <property name="timeToLive" value="1000000" />
             </default>
             </eviction>
            
             <clustering mode="i" clusterName="EmsGlobalCluster">
             <async />
             <jgroupsConfig configFile="udp.xml" />
             </clustering>
            
             <loaders passivation="false" shared="false">
             <loader class="org.jboss.cache.loader.ClusteredCacheLoader">
             <properties>
             timeout = 3000
             </properties>
             </loader>
             </loaders>
            
            </jbosscache>


            server:
            <?xml version="1.0" encoding="UTF-8"?>
            <jbosscache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xmlns="urn:jboss:jbosscache-core:config:3.1">
            
             <transaction
             transactionManagerLookupClass="org.jboss.cache.transaction.GenericTransactionManagerLookup" />
            
             <eviction wakeUpInterval="5000">
             <default algorithmClass="org.jboss.cache.eviction.LRUAlgorithm"
             eventQueueSize="200000">
             <property name="maxNodes" value="5000" />
             <property name="timeToLive" value="1000000" />
             </default>
             </eviction>
            
             <clustering mode="i" clusterName="EmsGlobalCluster">
             <async />
             <jgroupsConfig configFile="udp.xml" />
             </clustering>
            
             <loaders passivation="false" shared="true">
             <loader class="org.steeven.MyCacheLoader"
             async="false" fetchPersistentState="false" ignoreModifications="true"
             purgeOnStartup="false">
             <properties />
             </loader>
             </loaders>
            </jbosscache>


            • 3. Re: How to desing cache in Client/Server mode?
              Manik Surtani Master

               

              "steeven" wrote:

              another question, how to make the server readonly? the server will accept changes from client side. it is dangerous for my case.


              Hmm. You could make the client not push writes to the server by using the ignoreModifications attrib to the cacheLoader element.

              You could also write a custom interceptor on the server side (attach this to all server-side caches) to drop all write calls.