Introduction:This document consists of proof of concept details for the implementation of load balancing and high availability solution within the Helical Insight application.
Background : A web application hosted on a single node has many disadvantages mainly like unavailability in case of node failure and degraded performance in case of huge load.
To address these problems, we have designed a solution that hosts the application on multiple nodes which share the load and provide high availability.
Approach:
Solution Detail:
This section provides the High level explanation of the the solution.
- The HI application needs to be manually installed on multiple tomcats, preferable on different nodes.
- The application hosted on multiple nodes need to be configured to a single repository.
- A Apache HTTPD server need to be installed on one of the above nodes or separate node. This HTTPD server needs to be configured using the mod_jk algorithm with all of the available application tomcats.
- Clustering needs to be enabled within each of the tomcats.
User Story Details :
-
- Lets assume we have the HI application installed and setup on a two node clustered environment.
-
- User “A” accesses the Apache server which is configured to redirect the traffic to the available node. As per the configuration, the traffic is redirected to one of the available nodes i.e., lets say tomcat1.
-
- User “B” accesses the Apache server .If tomcat1 is busy then the traffic is redirected to the other available node i.e., lets say tomcat2.
- While navigating through the application as user “A”, lets assume that the serving tomcat, which in this case is tomcat1 becomes unresponsive/shuts down, then the traffic is automatically redirected to tomcat2. This proves the high availability functionality.
Prerequisites :
-
- Download and install the Apache HTTPD server(version 2.4 has been used in this POC) from the below link.
-
- Download and install two tomcat instances(version 7 has been used in this POC).
-
- Download and install tomcat connector mod_jk (version 1.2.40 has been used in this POC).
- Obtain the HI application tar ball(version 3.1.0 has been used in this POC).
- Download and install mysql server(version 8.0 has been used in this POC).
Phase wise configuration and testing of the POC :
Phase 1
- To setup apache httpd server
- To setup apache tomcat server 1
- To setupt apache tomcat server 2
- Setup up working module between httpd server with tomcat 1 and tomcat 2
- Create an index.jsp file which will print “hello from tomcat x” and keep it inside tomcat 1 and 2 to test the same
- LB and HA should be implemented in this case
Test cases
- stop tomcat 2 and check if the url is still serving from tomcat 1
- stop tomcat 1 and check if the url is still serving from tomcat 2
- test it with 100 threads and check occassinally we should be getting content from tomcat 1 and tomcat 2
Phase 2
- Install mysql
- Install HI on tomcat 1 pointing it to hi-repository and mysql
- Install HI on tomcat 2 pointing it to hi-repository and mysql
- Implement sticky session so that user should not be logged out in case of any failure of the server
- Follow phase 1 test case
Phase 3
- To be tested in separate h/w and n/w
Setting up the configuration :
The POC has been tested successfully on a standalone windows 10 64 bit machine.
-
- Apache HTTPD Configuration:
- Unzip the Apache server zip file into any desired location within your machine.
- Apache HTTPD Configuration:
-
-
- Create a new workers.properties file within the conf directory of the Apache server.
-
-
-
- Edit the workers.properties file as per below.
-
-
-
- Copy the mod_jk.so file from the downloaded tomcat-connector and place it in the modules folder of the Apache installation.
-
-
-
- Edit/add the httpd.conf file within the conf folder of Apache installation as per below.
-
-
- Tomcat Configuration :
- Edit/add the server.xml file within the conf directory of the tomcat installation.
- Tomcat Configuration :
-
-
- As the tomcats are running on the same node the boot-up, shutdown and AJP ports should be unique.
-
-
-
- Below details need to be added to configure clustering within the tomcats.
-
-
-
- Make the above changes within tomcat2 as well.
- Application Installation:
- Copy the hi-repository folder from the original installation and place it in a new path.
-
-
-
- Edit/add the below details within the settings.xml file of the hi-repository path “hi-repository\System\Admin”.
-
-
-
- Copy the hi-ee.war file from the original application installation path place it in the tomcat webapps folder.
- Now start the tomcat from command line using “catalina.bat start” command(abort the boot-up upon receiving an error).
- A new hi-ee application folder is now created within the webapps folder.
-
-
-
- Edit the files “application-context.xml”, “log4j.properties” and “project.properties” in the path “\webapps\hi-ee\WEB-INF\classes” as per below on each of the tomcats.
-
application-context.xml
Mention the mysql server details within the HikariDatasource and add the mysqldialect to replace apache derby database(default).
log4j.properties
Map this location to the common hi-repository.
project.properties
Map these locations to the common hi-repository location.
-
-
- Now redirect the default tomcat homepage within each of the tomcats by creating an index.html with the ROOT folder of the webapps.
-
The port number should be as per the tomcats port number.
Testing:
Phase 1:
Test cases
-
- Stop tomcat 2 and check if the url is still serving from tomcat 1
Results:
-
-
- Stopped tomcat2
-
-
-
- check if the url is still serving from tomcat 1
-
-
- Stop tomcat 1 and check if the url is still serving from tomcat 2
Results:
-
-
- Stopped tomcat1
-
-
-
- check if the url is still serving from tomcat 2
-
-
- Test it with 100 threads and check occasionally we should be getting content from tomcat 1 and tomcat 2
Results:
Using Bulk URL opener to hit the webpage with 100 threads
Phase 2
Test Cases
-
- Stop tomcat 2 and check if the application url is still serving requests.
Results:
-
-
- Stopped tomcat2
-
-
-
- check if the application url is still serving requests.
-
Results:
-
- Stop tomcat 1 and check if the url is still serving requests.
Results:
-
-
- Stopped tomcat1
-
-
-
- check if the url is serving requests.
-
-
- Test it with 100 threads and check occasionally we should be getting content from tomcat 1 and tomcat 2
Results: TBC
Phase 3
Results:
Using Bulk URL opener to hit the webpage with 100 threads
1st Thread:
49th Thread:
Thank You
Sai Charan
Helical Insight