4 Replies Latest reply on May 7, 2009 5:13 AM by Manik Surtani

    Fine-grained subtree replication

    Vladimir Ralev Newbie

      Two applications are deployed in the cluster, but a user wants the sessions from App1 to be replicated only to N/2 machines (to reduce network bandwidth since App1 has a very specific usage pattern that makes it so). App2 on the other hand should span the whole cluster. I am aware that you want to keep infifispan independent of any application specific data structures, but eventually people would want to have their app-specific or other data to be concentrated on particular machines and they could configure the load balancers to hit these machines with priority.

      So one solution to this is to use two different instances of JBAS on each machine, but that would be inefficient.

      Another solution is to support multiple buddy pools and have an API/SPI to select which subtrees in the cache are replicated to which pools. For example something like:
      app1, rarelyUsed, notImportant, generic, monitored, slowNetwork, linux, intercepted, secureNetwork, noWifi, etc in the cache configuration. Then some API to be used from containers like jboss-web or other apps:

      cache.put(fqn, value, new String[] {currentAppname, "generic", ... more tags}); // where currentAppName is just the appname from the current context, say it's "app1" in this case and the string array has all the tags


      Even better, this would enable users to put hints in the HTTP session about caching like

      cache.put(fqn, value, getCurrentHttpSession().getAttribute("org.jboss.cache.cacheHints"); // where the tags are takes from the current http session



      Or some other solution that allows:
      1. Selection of subsets of nodes
      2. Assignment of cache subtrees to such subset of nodes

        • 1. Re: Fine-grained subtree replication
          Manik Surtani Master

          That introduces a lot of app specific knowledge into the cache.

          A better approach is to set up different cache instances - perhaps one that uses replication and one that uses distribution, or perhaps both distribution but with different settings such as number of copies maintained.

          If using this within a WAR, your application could select which cache to use.

          If you are referring to HTTP session replication, keep in mind that this has not been implemented to use Infinispan as yet. But presumably you will be able to specify which cache instance to use for each specific webapp. In fact that may be a good feature request for the next version of JBoss AS that would use Infinispan.

          • 2. Re: Fine-grained subtree replication
            Vladimir Ralev Newbie

             

            "manik.surtani@jboss.com" wrote:

            If using this within a WAR, your application could select which cache to use.
            .


            Is this possible now or I need to talk to jb web team about it?

            • 3. Re: Fine-grained subtree replication
              Vladimir Ralev Newbie

               

              "manik.surtani@jboss.com" wrote:
              That introduces a lot of app specific knowledge into the cache.


              Just to make sure I explained correctly what I meant - some clarifications.

              The idea is exactly to avoid being aware of app specific data. Simply, instead of one buddy group id use multiple ids. The tags should NOT be interpreted by jb cache in any way, they are just ids. Each cache node would be configured by the deployer or the administrator with:
              <NodeTags>app1, rarelyUsed, notImportant, generic, monitored, slowNetwork, linux, intercepted, secureNetwork, noWifi</NodeTags>
              


              That tags represent app-specific, network-specific, security-specific, OS-specific, etc, but from cache point of view they are just some admin keywords.

              Using different instances of JB cache is fine of course and I am looking into it.

              • 4. Re: Fine-grained subtree replication
                Manik Surtani Master

                 

                "vladimir.ralev@jboss.com" wrote:
                "manik.surtani@jboss.com" wrote:

                If using this within a WAR, your application could select which cache to use.
                .


                Is this possible now or I need to talk to jb web team about it?


                What I meant by this has nothing to do with JBoss Web. I was talking about your custom code - which happens to be packaged in a WAR - that creates and starts an Infinispan cluster. Perhaps by starting it as an initializing servlet and then registering in somewhere (JNDI? A dependency injection container?) for other classes in your WAR to consume.