3.2.2. Buddy Replication

Buddy replication is a configuration in which state replication is limited to two or more cluster nodes, although the default is paired nodes. When failover occurs it's not limited to that node's buddy but can occur to any node and session information migrated to the new node if necessary. This method of replication is very scalable because the overhead in memory usage and network traffic is significantly decreased. Buddy replication is configured in a file called jboss-cache-manager-jboss-beans.xml, in the directory: JBOSS_EAP_DIST/jboss-as/server/<PROFILE>/deploy/cluster/jboss-cache-manager.sar/META-INF. Note that the default, standard and minimal configurations do not have the clustering configuration, nor do they have clustering code deployed.
<!-- Standard cache used for web sessions -->
       <bean name="StandardSessionCacheConfig" class="org.jboss.cache.config.Configuration">
               <property name="buddyReplicationConfig">
                     <bean class="org.jboss.cache.config.BuddyReplicationConfig">
                        <!--  Just set to true to turn on buddy replication -->
                        <property name="enabled">true</property>
For buddy replication to work as advertised, it is highly recommended that you use sticky sessions. In other words, once a session is created in a node on the cluster, repeated requests will continue to go to the same node in the cluster. If you don’t do this, you will defeat the advantages of buddy replication, as requests going to another node, let’s say in a round robin fashion, will not have the state information, and the state will have to be migrated, similar to a fail-over scenario.