Book Image

WildFly Configuration, Deployment, and Administration - Second Edition

Book Image

WildFly Configuration, Deployment, and Administration - Second Edition

Overview of this book

Table of Contents (19 chapters)
WildFly Configuration, Deployment, and Administration Second Edition
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Load-balancing between nodes


We will run a couple of tests in order to investigate how mod_cluster distributes the load between several different clients.

For these tests, we will use a very basic web application. The application source can be found with the source code for this book; the project is called chapter9-balancer. It contains a simple index.jsp page, which dumps a message on the console:

<%
Integer counter = (Integer)session.getAttribute("counter");
if (counter == null) {
  session.setAttribute("counter",new Integer(1));
}
else {
  session.setAttribute("counter",new Integer(counter+1));
}
System.out.println("Counter"+session.getAttribute("counter"));          
%>

After deploying the application, go to the URL http://192.168.0.10/balancer/index.jsp. After making several requests, you will see that each subsequent request is sent to the same server. This shows that mod_cluster follows a sticky-session policy. Have a look at the following screenshot:

For the purpose of our tests...