Usually, a hardware load balancer is placed in front of all of these
machines. The load balancer receives a request from the client and decides which
machine in the cluster to forward this request to based on a preconfigured set of
algorithms. In general, this keeps each machine in the cluster equally loaded, so no
single machine??™s resources are exhausted. Software-based load balancers exist as well.
For example, Tomcat comes bundled with a software-based load balancer, which
resides as a Web application in tomcat_dir/webapps/balancer.
In this environment, it is quite possible for a client to be served by different
machines from one request to another. Yet, to the client, it all looks like a single Web
application. For example, you can be served by machine A to display a list of items in
your online shopping cart. When you click the Complete Purchase button, it might
be machine B that sends the Payment Options screen to your browser. The information
about who you are as a user as well as your session data is shared between
machine A and machine B.
This behavior is achieved by sharing the HttpSession among the machines in
the cluster. Even though each machine in the cluster has its own Java Virtual
Machine (JVM), the HttpSession object gets copied and shared among the cluster.
Because clustered Web applications run in multiple JVMs, you may not rely on
the usual mechanisms of sharing data used in regular Web applications.
Pages:
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140