2. CONTENTS
What is Clustering
Clustering Goals
Implementation
Load Balancing Basics
Clustering jboss AS
Clustering Web Application
Demo
3. WHAT IS CLUSTERING
Clustering allows you to run an application on several parallel servers
(cluster nodes) while providing a single view to application clients.
Load is distributed across different servers, and even if one or more of
the servers fails, the application is still accessible via the surviving
cluster nodes.
Clustering is crucial for scalable enterprise applications, as you can
improve performance by adding more nodes to the cluster.
Clustering is crucial for highly available enterprise applications, as it is
the clustering infrastructure that supports the redundancy needed for
high availability.
4. CLUSTERING GOALS
No single SPOF (Single Point Of Failure)
Ability to increase application throughput by adding hardware
(Horizontal Scaling vs Vertical Scaling)
Fault Tolerant
Load Balancing
6. LOAD BALANCING BASICS
Apache vs Nginx
Load balancing Algorithms
Random
Round Robin
Weight Based
Health checks
Session stickiness vs ip-hash
7. CLUSTERING JBOSS AS (1/2)
“all” Configuration
Clustering Support
Create multiple copies to run several instances on a single machine
Partition
The default name is "DefaultPartition". We can use separate names to segregate Development and Production Environment.
Multicast
By default JBoss AS uses UDP multicast for most intra-cluster communication.
Pick a different multicast address for each cluster you run.
Generally a good multicast address is of the form 239.255.x.y.
Socket Binding
Use of IP Address instead of 0.0.0.0
Requirement of offset in-case of multiple instances on a single machine
Server Peer ID
This is needed for JBoss Messaging across clusters
Changes in server.xml (Access Logger)
8. CLUSTERING JBOSS AS (2/2)
Command for starting jboss cluster on separate physical severs
./run.sh -c node1 -g APPSERVER -u 239.255.100.100 -b 192.168.1.1 -
Djboss.messaging.ServerPeerID=1
./run.sh -c node2 -g APPSERVER -u 239.255.100.100 -b 192.168.1.2 -
Djboss.messaging.ServerPeerID=2
Command for starting jboss cluster on a single physical sever
./run.sh -c node1 -g APPSERVER -u 239.255.100.100 -b 0.0.0.0 -
Djboss.messaging.ServerPeerID=1 -Djboss.service.binding.set=ports-01
./run.sh -c node2 -g APPSERVER -u 239.255.100.100 -b 0.0.0.0 -
Djboss.messaging.ServerPeerID=2 -Djboss.service.binding.set=ports-02
9. CLUSTERING APPLICATION
Dos
Add <distributable/> tag in web.xml
Serialize all http session beans
Implement Quartz Cluster Scheduler
Using a third party cache provider (EHCache+RMI) to minimize database hits
Application should be deployable on “touch” of web.xml similarly should get un-deploy
on renaming it to .bak
Don'ts
Avoid using static maps, get data from database when required
Avoid using I/O operations (document upload) otherwise use a common repository
Avoid using Application Context unless its read-only
Avoid using complex object in http session to keep replication state minimal
Synchronization block in code will no longer work