Sie sind auf Seite 1von 8

SCALING JBOSS APPLICATIONS

Author: Joe Negem


Creation Date: 17/12/2010
Last Revised: 18/12/2010
Version: 0.1
Scaling JBoss AS

CONTENTS
Contents..................................................................................................................... 2
Introduction................................................................................................................ 3
Cluster basics.............................................................................................................3
Multicasting................................................................................................................4
JGroups....................................................................................................................... 4
JBoss AS Clustering Architecture................................................................................5
Smart Proxies.......................................................................................................5
External Load Balancer........................................................................................6
Cluster Configuration..................................................................................................7
Implementing a cluster...............................................................................................8
Conclusion.................................................................................................................. 8

FIGURES
Figure 1 - JBoss cluster architecture...........................................................................5
Figure 2 - Smart proxy and load balancing architecture.............................................7

May 7, 2011 Version 2


Scaling JBoss AS

INTRODUCTION
JBoss clustering is not the product of a single library or specification, but rather a
blend of technologies. Clustering is a method of turning multiple computer servers
in a group of servers that act like a single system. Whilst a single instance of JBoss
can handle several hundred concurrent requests, if your application requires that
much more demand be placed on the application, the single server will not satisfy
your requirements. JBoss allows a JEE application to run across multiple servers.
Requests going to your application server can then be balanced across these
servers, with the added bonus that the application can withstand individual
application server failures (failover).

The JEE specification does not mandate or describe a particular approach to


clustering. It is left to the individual application server vendors to provide varying
tools and techniques to achieve the applications clustering objectives. The good
news is that Red Hat makes setting up and maintaining a cluster of JBoss servers a
painless undertaking. This document assumes that either JBoss AS 5 or JBoss AS 6 is
being used.

CLUSTER BASICS
A cluster of application servers comprises of multiple server instances (nodes) that
run simultaneously and work in concert to provide increased scalability and
reliability of the application. This allows for greater loads to be placed on that
application that would not be possible in a single instance. The cluster nodes can be
located on the same physical machine, or distributed across a network. From the
perspective of the client, this is all abstracted away because the cluster appears as
a single server instance.

Introducing clustering to your application will provide the following benefits:-

Scalability: Adding a new node to a cluster should allow the overall system to
service a higher client load than that provided by the simple basic configuration.
Ideally, it should be possible to service any given load, simply by adding the
appropriate number of servers or machines.

Load balancing: In a clustered environment, the individual nodes composing the


cluster should each process a fair share of the overall client load. This can be
achieved by distributing client requests across multiple servers, also known as load
balancing.

May 7, 2011 Version 3


Scaling JBoss AS

High Availability: When a server instance fails in a cluster, the application will
continue running. In a multi-node environment, loss of a single node is not
catastrophic, as another node can continue application processing.

MULTICASTING
Multicasting is an important topic in JBoss clustering. Multicasting allows for
simultaneous communication between interested parties over a network. One-to-
many and many-to-many techniques can be employed for real-time communication.
It scales to a large receiver population by not requiring prior knowledge of the
number of receivers. Please refer to Wikipedia for further information. Note that the
total routing schemes available in multicasting are:

- Unicast

- Anycast

- Multicast

- Broadcast

- Geocast

JGROUPS
JGroups is a core communication component in JBoss. Communication between
nodes is not handled directly by the cluster, but via the JGroups library. JGroups
provides reliable multicast transmission. The basic building block of JGroups is the
channel, which is similar to a standard socket. Channels are the means by which
applications connect to a cluster and exchange messages.

At server startup, the JGroups library launches a set of channels which have the
ability to discover each other dynamically via IP multicasting. Nodes that join the
cluster at a later stage have their state automatically synchronized with the rest of
the group.

The second core component in JGroups is the protocol stack. This stack is a set of
protocol layers that are organized in a bi-directional heap. For example, the
fragmentation layer breaks up a message into several messages, adding a header
with an ID to each fragment. On the receiver side, each fragment is re-assembled
and from which the ID is extracted.

May 7, 2011 Version 4


Scaling JBoss AS

JBOSS AS CLUSTERING ARCHITECTURE


JBoss AS cluster solutions exist in two forms, Smart Proxy Architecture and External
Load Balancer. In a nutshell, external load balancer is used by clustered web
applications, while smart proxies are used for all other clusterable components.

FIGURE 1 - JBOSS CLUSTER ARCHITECTURE

Note that the bottom tier depicts the individual JEE components that can be
clustered. These are the technological entities which can be scaled via the cluster
paradigm.

SMART PROXIES

May 7, 2011 Version 5


Scaling JBoss AS

JNDI, EJB, RMI and JBoss remoting does not use peer-to-peer communication. For
example, when a client invokes an EJB, an object named smart proxy is looked up
and downloaded locally. In a single node environment, the smart proxy must only
pursue the job of routing the call from the client to the server, marshalling
parameters and unmarhsalling EJB return values. In a clustered environment, the
smart proxy object includes an interceptor that understands how to route calls to
multiple nodes in the cluster. The smart proxy is constantly aware of the clustering
topology—for example, if one node of the cluster fails, the proxy stub is updated to
reflect the latest changes in the cluster.

EXTERNAL LOAD BALANCER


Load balancing web applications involves configuring an external component that
contains the logic to route the request to the nodes hosting the web application. This
can be done via hardware of software; however they perform conceptually the same
function, spreading requests across the nodes. Apache HTTP server is a popular way of
achieving load balancing via software, namely the Apache mod_jk plug-in.

Figure 2 below illustrates the differences between the smart proxy and the load
balancing technique.

May 7, 2011 Version 6


Scaling JBoss AS

FIGURE 2 - SMART PROXY AND LOAD BALANCING ARCHITECTURE

The dynamic proxy understand the topology of the cluster is able to re-route
requests to an available node should one become inactive. It achieves this by
intercepting client requests and acting on changes to the cluster configuration in
real-time. The load balancer is programmed with a failover technique and is able to
send requests to a new node once it is aware of a failed node. The load balancer is
an external component to JBoss and can be either hardware of software based.

CLUSTER CONFIGURATION
In JBoss AS 5, cluster configuration is centralized in the deploy/cluster directory.
There are quite a few areas that need to be configured. Each file is responsible for a
particular item in the cluster config. This allows for an elegant separation of
concerns in the layout and management of the cluster. The most important files are
listed and described in Table 1 below.

May 7, 2011 Version 7


Scaling JBoss AS

TABLE 1 - JBOSS CLUSTER CONFIG. FILES

File Description
Jboss-cache-manager-jboss- JBoss Cache configuration file. Used for HTTP
beans.xml and SFSB replication and for Entity cache
replication.
jboss-cache-configs.xmlcaption Additional JBoss Cache configurations using
the standard JBC 3.x config format can be
stored here.
jgroups-channelfactory-jboss- JGroups JChannel Factory configuration.
beans.xml
jgroups-channelfactory- Standard JGroups protocol stacks definitions,
stacks.xml used by the JChannelFactory bean.
deploy-hasingleton-jboss- HA Singleton configuration
beans.xml
hajndi-jboss-beans.xml HA-JNDI configuration
ha-legacy-jboss-beans.xml HA legacy services configuration
hapartition-jboss-beans.xml HA Partition configuration

IMPLEMENTING A CLUSTER
Red Boss is able to assist any organization in implementing and supporting a JEE
environment which requires the load and availability values provided in a JBoss
cluster. We have many years of experience building and supporting large scale JEE
projects, and would be happy to assist you with your project requirements.

CONCLUSION
This document has described the benefits of building a cluster with JBoss. Clustering
achieves the goals of high application load as well as failover. The underlying
technologies that are fundamental to a JBoss cluster have been described. The
combination of JGroups and multicasting underpin the platform of the Red Hat JBoss
cluster. The technology team has been provided with an easy to user set of
configuration files to allow for the provisioning of a JBoss cluster, making the
process an efficient and effective undertaking.

May 7, 2011 Version 8