Testing of the clustered instance

To perform cluster testing, we are going to take you through a sequence of events. In the following event, we only plan to use two Tomcat instances—tomcatnode1 and tomcatnode2. We will cover the following sequence of events:

  1. Start tomcatnode1.
  2. Start tomcatnode2 (wait for node 1 to start completely).
  3. Node 1 crashes.
  4. Node 2 takes over the user session of node 1 to node 2.
  5. Start node 1 (wait for node 1 to start completely).
  6. Node 2 and node 1 are in running state.

Now we have a good scenario with us, we will walk through how the entire process works:

  1. Start instance 1: tomcatnode1 starts up using the standard startup sequence. When the host object is created, a cluster object is associated with it. Tomcat asks the cluster class (in this case SimpleTcpCluster) to create a manager for the cluster and the cluster class will start up a membership service.

    Note

    The membership service is a mechanism in the cluster instance through the cluster domain, which adds the member node in the cluster. In simple terms, it is a service through which members are able to join the cluster.

  2. Start instance 2: When Tomcat instance 2 starts up, it follows the same sequence as tomcatnode2 with one difference. The cluster is started and will establish a connection (tomcatnode1, tomcatnode2). tomcatnode2 will now send a request to the server that already exists in the cluster, which is now tomcatinstance2.

    Tip

    In case the Tomcat instance does not respond within an interval of 60 seconds, then Tomcat instance 2 will update the cluster, and generate the entry in the logs.

  3. Node 1 crashes: Once the Tomcat instance crashes, the cluster manager will send a notification to all the members, in our case it's tomcatnode2. The entire session of node 1 will be replicated to node 2, but the user will not see any issues while browsing the website.
  4. Node 2 will take over the user session of node 1 to node 2: tomcatnode2 will process the request as with any other request. User requests are served with node 2.
  5. Start instance 1: Upon start up, tomcatnode1 first joins the cluster, and then contacts tomcatnode2 for the current state of all the users in the session. It starts serving the user requests and shares the load for node 2.
  6. Node 2 and node 1 are in running state: Now both the instances are in running state. Node 2 will continue to serve the user requests and once the request is served, it will terminate the user session.

If the previous mentioned test is working, it means clustering is working fine.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.216.230.107