Enabling clustering for load balancing and failover

Load balancing is an enterprise-level feature in which the application server automatically alternates requests among the server instances in a cluster. Clustering also enables application servers to route requests to a running server instance when the original server instance goes down.

Note: These instructions apply only when you are running ColdFusion in the multiserver configuration. If you are running Tomcat, you can also create clusters in the JMC.

You can get load balancing and failover by deploying identical ColdFusion applications and configurations to multiple server instances and adding the instances to a cluster. Each instance must have the same applications deployed and the same resources configured (such as data sources, Solr collections, and mappings). The web server connector optimizes performance and stability by automatically balancing load and by switching requests to another server instance when a server instance stops running.

Note: Because clustering uses Jini Network Technology, you must be connected to a network for clustering to work.

For maximum failover protection, use multiple computers in a cluster. However, purchase a separate ColdFusion Enterprise Edition license for each computer.

To implement session failover for the server instances in a cluster, enable session replication for each server instance. Session replication coordinates session information in real time among the server instances in a cluster. Enabling session replication lets Tomcat automatically route a request to a running server if the current server is unavailable.

Note: When a cluster uses session replication, session data is copied to other servers in the cluster each time it is modified. This can degrade performance if you store a significant amount of information in session scope. If you plan to store a significant amount of information in session scope, consider storing this information in client variables saved in a database.

Configure a cluster of server instances for load balancing and failover

Manage clusters using the ColdFusion Administrator.

  1. In the ColdFusion Administrator, click Enterprise Manager > Cluster Manager.

  2. Enter a cluster name and then click Add.

  3. Click the cluster name and move the servers to the cluster based on the requirement.

  4. (If required) Edit the multicast port.

    Multicast port is used to group the cluster members together. Default value of multicast port is 45564. After you create a cluster, the port is added in the cfroot\cfusion\config\cluster.xml file.

    For more information on multicast port, see http://tomcat.apache.org/tomcat-6.0-doc/config/cluster-membership.html.

  5. Specify if you need sticky session.

    Sticky session ensures that after a session is established on an instance, all future requests from the client are mapped to that instance.

  6. Click Submit.

Adding a remote instance to a cluster

To add a remote instance to a cluster, add the cluster block to the remote instance’s server.xml. Then, register the remote instance and add the instance to the cluster. For more information on configuring clusters on Tomcat, see http://tomcat.apache.org/tomcat-5.5-doc/cluster-howto.html.
  1. Register the remote instance to the local machine.

  2. Create a cluster in the local machine.

  3. Open the cfroot\instance-name\runtime\conf\server.xml file of the remote instance.

  4. Add the following block between the entries </host> and </engine>:

     
    <Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"         channelSendOptions="8"> 
        <Manager notifyListenersOnReplication="true" expireSessionsOnShutdown="false" className="org.apache.catalina.ha.session.DeltaManager"> 
        </Manager> 
        <Channel className="org.apache.catalina.tribes.group.GroupChannel"> 
            <Membership port="45565" dropTime="3000" address="228.0.0.4"     className="org.apache.catalina.tribes.membership.McastService" frequency="500"> 
            </Membership> 
            <Receiver port="4003" autoBind="100" address="auto" selectorTimeout="5000"     maxThreads="6" className="org.apache.catalina.tribes.transport.nio.NioReceiver"> 
            </Receiver> 
            <Sender className="org.apache.catalina.tribes.transport.ReplicationTransmitter"> 
                <Transport className="org.apache.catalina.tribes.transport.nio.PooledParallelSender"> 
                </Transport> 
            </Sender> 
            <Interceptor className="org.apache.catalina.tribes.group.interceptors.TcpFailureDetector"> 
            </Interceptor> 
            <Interceptor     className="org.apache.catalina.tribes.group.interceptors.MessageDispatch15Interceptor"> 
            </Interceptor> 
        </Channel> 
        <Valve className="org.apache.catalina.ha.tcp.ReplicationValve" filter=""> 
        </Valve> 
        <Valve className="org.apache.catalina.ha.session.JvmRouteBinderValve"> 
        </Valve> 
     
        <ClusterListener     className="org.apache.catalina.ha.session.JvmRouteSessionIDBinderListener"> 
        </ClusterListener> 
        <ClusterListener className="org.apache.catalina.ha.session.ClusterSessionListener"> 
        </ClusterListener> 
     
    </Cluster> 
  5. In the entry, update the membership port with the multicast port of the cluster.

  6. Using the ColdFusion Administrator of the local host, add the local instance and the remote instance to the cluster.
    Note: If you enable sticky session, the JVM route of the remote instance and local instance must not be the same.
  7. Restart all the instances.