J2EE clustering, Part 2
Migrate your application from a single machine to a cluster, the easy way
By Abraham Kang, JavaWorld.com, 08/03/01
- Digg
- Reddit
- SlashDot
- Stumble
- del.icio.us
- Technorati
- dzone
Within the J2EE framework, clusters provide an infrastructure for high availability (HA) and scalability. A
cluster is a group of application servers that transparently run your J2EE application as if the group were a single entity. However,
Web applications behave differently when they are clustered as they must share application objects with other cluster members
through serialization. Moreover, you'll have to contend with the extra configuration and setup time.
To avoid major Web application rework and redesign, you should from the very beginning of your development process consider
cluster-related programming issues, as well as critical setup and configuration decisions in order to support intelligent
load balancing and failover. Finally, you will need to have a management strategy to handle failures.
Read the whole "J2EE clustering" series:
Building on the information in Part 1, I'll impart an applied understanding of clustering. Further, I'll examine clustering-related issues and their possible solutions,
as well as the advantages and disadvantages of each choice. I'll also demonstrate programming guidelines for clustering. Finally,
I'll show you how to prepare for outages. (Note that, due to licensing constraints, this article will not cover benchmarking.)
Set up your cluster
During cluster setup, you need to make important decisions. First, you have to choose a load balancing method. Second, you
must decide how to support server affinity. Finally, you need to determine how you will deploy the server instances among
clustered nodes.
Load balancing
You can choose between two generally recognized options for load balancing a cluster: DNS (Domain Name Service) round robin or hardware load balancers.
DNS round robin
DNS is the process by which a logical name (i.e., www.javaworld.com) is converted to an IP address. In DNS round-robin load
balancing, a single logical name can return any IP address of the machines in a cluster.
DNS round-robin load balancing's advantages include:
- Cheap and easy setup
- Simplicity
Its disadvantages include:
- No server affinity support. When a user receives an IP address, it is cached on the browser. Once the cache expires, the user makes another request for
the IP address associated with a logical name. That second request can return the IP address of any other machine in the cluster,
resulting in a lost session.
- No HA support. Imagine a cluster of n servers. If one of those servers goes down, every nth request to the DNS server will go to the dead server.
- Changes to the cluster take time to propagate to the rest of the Internet. Many corporations' and ISPs' DNS servers cache DNS lookups from their clients. Even if your DNS list of servers in the cluster
could change dynamically, it would take time for the cached entries on other DNS servers to expire. For example, after a downed
server is removed from your cluster's DNS list, AOL clients could still attempt to hit the downed server if AOL's DNS servers
cached entries to the downed server. As a result, AOL users would not be able connect to your site even if other machines
in the cluster were available.
- No guarantee of equal client distribution across all servers in the cluster. If you don't configure cooperating DNS servers to support DNS load balancing, they could take only the first IP address returned
from the initial lookup and use that for their client requests. Imagine a partner corporation with thousands of employees
all pinned to a single server in your cluster!
Hardware load balancers
In contrast, a hardware load balancer (like F5's Big IP) solves most of these problems through virtual IP addressing. A load
balancer presents to the world a single IP address for the cluster. The load balancer receives each request and rewrites headers
to point to other machines in the cluster. If you remove any machine in the cluster, the changes take effect immediately.
- Digg
- Reddit
- SlashDot
- Stumble
- del.icio.us
- Technorati
- dzone
Resources
- "J2EE Clustering," Abraham Kang (JavaWorld):
-
- Enterprise hosting services:
-
- Hardware load balancers:
-
- Enterprise JavaBeans, Richard Monson-Haefel (O'Reilly & Associates, 2000; ISBN1565928695)
http://www.amazon.com/exec/obidos/ASIN/1565928695/javaworld
- Java PitfallsTime-Saving Solutions and Workarounds to Improve Programs, Michael C. Daconta (Editor), Eric Monk, J. Paul Keller, Keith Bohnenberger (John Wiley & Sons, 2000; ISBN0471361747)
http://www.amazon.com/exec/obidos/ASIN/0471361747/javaworld
- "Flatten Your Objects," Todd M. Greanier (JavaWorld, July 2000)
http://www.javaworld.com/javaworld/jw-07-2000/jw-0714-flatten.html
- For a good look at the canonical form, read Bill Venners' "The Canonical Object Idiom" (JavaWorld, October 1998)
http://www.javaworld.com/javaworld/jw-10-1998/jw-10-techniques.html
- For more information on high availability, see the High-Availability Linux Project
http://www.linux-ha.org
- "Get the App Out," Chang Sau Sheong (JavaWorld, January 2001) describes the ins and outs of J2EE assembly and deployment
http://www.javaworld.com/javaworld/jw-01-2001/jw-0119-j2eeassembly.html
- For more JavaWorld articles covering J2EE, visit the Server-Side Java section of our Topical Index: http://www.javaworld.com/javaworld/topicalindex/jw-ti-ssj.html
- Sign up for the JavaWorld This Week free weekly email newsletter to learn what's new at JavaWorld: http://www.idg.net/jw-subscribe
- You'll find a wealth of IT-related articles from our sister publications at IDG.net