Life with NGASI
- All
- General
Load Balancing Glassfish on Amazon EC2
Overview
You have probably heard how easy it is to install and manage Load-Balanced
farms of Tomcat and JBoss with NGASI AppServer Manager. Well it is just as easy for
Glassfish. I will illustrate how-to with NGASI Hosted on Amazon EC2 (requires an
Amazon EC2 account; of course you may download and install your own version of NGASI
AppServer Manager if you do not have an Amazon EC2 account.)
Background
Load balancing is a server technique to spread the load of an application across multiple
servers. It is comprised of 2 or more application servers, the load-balancer, and often
times a database server shared by the application servers. The purpose for wanting
load-balancing are varied. Load-balancing is mostly used for high-load and or high-traffic
applications; and also for high availability. If a server goes down, the traffic
fails-over to other servers, which will continue serving requests.
The load-balanced setup are often referred to as a cluster or farm. The member servers are
referred to as nodes. The nodes in the load-balanced farm are proxied by a load balancer
device. The load balancer may be a hardware or software based. The load balancer accepts
requests, and directs the requests to the appropriate application server. The load
balancer also keeps track of sessions (referred to as sticky sessions), so that subsequent
requests would be forwarded to the originating application server.
Load Balancing Glassfish Application Server Cluster
Load-balancing a cluster of Glassfish application servers, follows the principles outlined
above. Below are some general steps to follow:
1)Setup the Database to be shared by the nodes
2)Install and configure 2 or more Glassfish instances (preferably on separate machines).
3)Deploy the Application to the various nodes (Glassfish instances).
4)Configure the load-balancer. Set the loadfactor for the various nodes. Known load-balancers
include Sun's Load Balancer plugin, Apache mod_proxy and mod_jk. Jan Luehe's Blog,
"How to Loadbalance GlassFish Cluster with Apache Loadbalancer"
(http://blogs.sun.com/jluehe/entry/supporting_apache_loadbalancer_with_glassfish), details
the steps to configure Apache mod_jk as a load-balancer for a Glassfish cluster.
Now you can see how laborious and potentially error prone this process can become as the number
of nodes increases; for example a load-balanced farm compromised of 6 or more nodes.
NGASI AppServer Manager solves this dilemma by automating the process.
Load-Balancing Glassfish Automation with NGASI AppServer Manager
If load-balancing many Glassfish servers, NGASI AppServer Manager offers an alternative solution
that automates the process from end-to-end. This can be achieved via the NGASI web interface or
the API. I will explain the web interface how-to.
The NGASI AppServer breaks the process into several stages:
- Setting up Remote Servers for the cluster nodes and load-balancer
- Configuring Apache on one of the Remote Server (as the load balancer)
- Adding System users for the Glassfish Application Server to run under.
- Set IP Addresses and Ports for the nodes
- Install Glassfish Application Server for one of the nodes.
- Define load-balancing configuration
- Configure load-balancing device (software)
- Add nodes
- Synchronize nodes
For those without an Amazon EC2 account please jump to step 11).
1)First you need to register your free developer account
2)Point your browser to https://ssl.ngasi.com/zp/ngweb/ngwportal.zul
3)Click the "Create Account" tab.
4)Enter the appropriate information required for registration
5)Check your email for access info
6)Authenticate with the access information
7)Once logged in, click the "Add" button to created a NGASI Hosted account for Amazon EC2
8)Enter the appropriate information then Click "Save".
9)You will then see Access information for your NGASI Hosted account for Amazon EC2.
10)Use the information above to Login to NGASI AppServer Manager.
11)Login to NGASI AppServer Manager
12)Setting up Remote Servers for the cluster nodes and load-balancer
The first step would be to add Remote Server(s) as described below.
In order to interact with the remote server, NGASI AppServer Manager requires the password or
Public/Private Key for the root system of the remote user. The SSH protocol is used for secured
communication. For Amazon EC2, Private Key is required.
Click the "Remote Servers" Tab [
].
Enter the appropriate information in the Form.
Click "Save" to add Remote Server [
] with the appropriate information.
(Ideally, you should add at least 3 Remote Servers. 2 for the nodes and 1 for the load-balancer.
NOTE: for testing purposes you may use 1 remote server for the entire Load-balancing cluster.)
12)Configuring Apache on one of the Remote Servers (as the load balancer)
NGASI AppServer Manager needs to know certain information about the Apache Web Server,
such as configuration file, executable, etc. This is done by following the steps below:
Click the Remote Servers Tab [
].
Click the Web tab.
Enter and save the appropriate Apache configuration.
13)Adding System users for the Glassfish Application Server to run under.
[
]
Assigning Access to NGASI - Account Users
Click the "Accounts" Fisheye menu item
Click the "Add User" Tab
Select one of the "Available System Users".
Then select a corresponding Group
Click "Add" to add the user as an Account user for the NGASI AppServer Manager
You may create a System user if not exist by entering the desired name in the text area of the
"Available System Users". You must include the remote server name along with the system user
name like so:
myuser:/remoteservername.
(Ideally, you should add at least 2 System users on 2 separate Remote Servers for 2 nodes.
NOTE: for testing purposes you may use 1 remote server for the entire Load-balancing cluster.)
14)Set IP Addresses and Ports for the nodes
If system user is on a different server to the load-balancer, set the system user configuration with
an IP address accessible from the load-balancer (non-localhost).
Make sure port (8080,8009) access are not blocked by a Firewall
Click the "Users List" Tab
Select the User
Click the "Edit" Button
Enter the appropriate IP Address and port info
Click "Update" to complete
Repeat steps for other nodes
15)Install Glassfish Application Server for one of the nodes.
This user will be used as the Primary node (used for syncing other nodes)(refer to step 18).
Install Glassfish Application Server for Primary node System user by following the steps below:
As the Administrator of NGASI User Accounts, you are able to quickly Login as the user, then Login back
as Admin.
Click the "Accounts" Fisheye menu item.
Click the "Users List" Tab
Select the User
Click the [
] Icon
Click the "AppServer Manager" Fisheye menu item
Click the "Install" tab
Select the Application Server (Glassfish) and version you would like to install
Click "Setup" to proceed
To Login back as Admin, click the "Admin" link in the Account User's console.
16)Define load-balancing configuration
Click the "Services" Fisheye menu item. Then click the "Load Balance" Tab to proceed.
[
] --> [
]
Click the "New" Button
Select the Application Server (Glassfish) and version you would like for the cluster
Click "Save".
17)Configure load-balancing device (software)
Click the "Balancer" Tab
Select the Remote Server to be used as the Load-balancer and enter the other pertinent information.
Click "Save".
18)Add nodes
Click the "Nodes" Tab
Add Nodes from the "Available Nodes" Tab.
Set Primary Node to the System user with the installed Glassfish Application server (refer back to step 15)
19)Synchronize nodes
Finally click "Synchronize All". This final step installs and configures the Glassfish Application server
to the other nodes. Configures the Application servers for load-balancing. And configures the
load-balancer to be ready to direct requests to the various nodes.
Summary
To recap, Load-balancing is an important consideration for scalability and high availability.
With proper application design, this can be achieved with the Glassfish Application server as
the basis for the nodes and Apache as the load-balancer. Combined with NGASI AppServer Manager,
many of the steps in the Load-balancing process can be automated, thus freeing up time and other
resources.
Posted at 03:51AM Aug 21, 2008 by thespartan in General | Comments[1]
