An Introduction to JBoss Cloud
Join the DZone community and get the full member experience.Join For Free
Running services continuously, without downtime is a very important task for administrators. Having to deal with a large number of nodes in a cluster and setting up and configuring new nodes aren't always easy tasks for system maintainers when the computing power that's delivered isn't sufficient.JBoss Cloud provides a preconfigured cloud of JBoss Application Servers and supporting technologies out-of-the-box. All you need to do is deploy your application and start using it.
This article is going to discuss what JBoss Cloud is, how to use and customize it.
Defining the Cloud
For the purposes of this article, here's how I am defining the term 'cloud':
- Based on full operating system virtualization
- Easy to use
Running clustered services doesn't constitute a cloud by itself. To be a cloud, there needs to be a full operating system stack with all services on top of a selected virtualization platform. This platform could be anything that you are familiar with. JBoss Cloud supports Xen, KVM, VMware and Amazon EC2 at this time.
What's the difference between a public and private cloud?
A private cloud can be run internally in your data center, or on your hardware. Public clouds are usually run on hardware provided by a hosting
The cloud should be scalable. In the event that you maximize power utilization in your current cloud configuration you should be able to increase it's computing resources in minutes, without interrupting any currently running services.
Managing a cloud should be easy and provide a uniform way to do management tasks such as powering up new nodes.
JBoss Cloud was designed with these requirements in mind.
JBoss Cloud at workBy default JBoss Cloud consists of one front-end appliance and one or more back-end appliances. An appliance is a fully operational system, with disks, network cards, operating system and preconfigured applications. A front-end appliance is a system running Apache HTTPD with mod_cluster and a Gossip Router. A back-end appliance is a JBoss AS 5 instance. Back-end appliances can talk together if they're running in cluster mode. There is also a postgis appliance available with preconfigured PostgreSQL.
At the core of JBoss Cloud is JBoss Application Server 5. This application server provides a foundation for running Java EE 5 application and has built-in clustering support. In a cluster there are two major topologies: cluster and group. In group topology no session data is transferred between nodes in the cluster. You would use a group topology when there is no need to have a full, replicated cluster, because nodes are used only to increase throughput and losing session data is acceptable in the case of a node crash.
Every cluster needs a load balancer. We're using Apache HTTPD as a load balancer, together with a mod_cluster module. This module discovers all nodes in a cluster and redirects requests to them. It is smart enough to redirect requests to nodes with more power than others. Every JBoss AS node computes its own load balance factor which it sends to the load balancer. Support for session affinity, SSL or more than one load balancer in a cluster is also built-in. Read more on the mod_cluster homepage.
Detecting nodes by mod_cluster can be done automatically via multicasting, but in some virtualization environments multicast isn't available (eg. VMware). Because of that that we're using a Gossip Router to transfer data between nodes and the load balancer. This is located in the front-end appliance.
How does it all work?After a back-end appliance is started it registers itself on the front-end appliance. It then begins checking for contexts in a node (you can run multiple applications on one server with different contexts, eg. /portal, /test). A context list for each node is stored in load balancer memory. When a client sends a request, the load balancer checks if there is such a context available. If not, it will redirect to a 404 page for example. But if there is such a context, the load balancer will check if this session was active before. If yes, it'll redirect this request to the last used node, because sticky sessions are enabled. In the case of a new session, the load balancer will search for all nodes with the selected context. The node with the lowest usage factor will win and the load balancer will redirect the request to it.
Starting a new back-end appliance does nothing more than register it in the load balancer. After that it is immediately available for serving requests, so expanding the capacity of a cloud is almost automatic.
RequirementsThe only real requirement is the virtualization environment. To run JBoss Cloud you should have access to one of these: Xen, KVM, VMware or Amazon EC2. Notice that there is no need to have static IP addresses, JBoss Cloud works great in DHCP enabled environments. Many environments restrict or inhibit multicast, which JBoss Cloud also accounts for.
A reasonable minimum for a back-end appliance should be 512 MB of RAM. Front-end appliances could be run with 256 MB of RAM. The default size of hard drives is 2 GB, but you can customize it by building yourself an appliance if this doesn't work for you.
Setting it all upUsing JBoss Cloud is really simple. If you're using VMware or XEN, grab our images and boot one front-end appliance and a few back-end appliances. On Amazon just search for our AMIs and launch them! Refer to VMware and EC2 pages on how to launch appliances.
There is also a VM2 project for emulating EC2 locally, on VMware. Currently it supports only VMware Fusion on Mac OS X. If you're lucky enough and have such a combination, then you will be able to run a fully functional cloud directly from your command line in seconds.
After the cloud is started you can install your application by simply copying it to all nodes in the cluster (we're working on a simpler way). After it is deployed, it will be automatically available for clients.
Creating your own appliances
JBoss Cloud is really a set of Ruby scripts and Rake tasks and it's open source! JBoss Cloud is shipped with a few appliances preconfigured: front-end, back-end, postgis and meta appliance. Meta appliance is a special case appliance used for creating other appliances.
If this isn't sufficient, you can also build your own appliances. You can grab JBoss Cloud sources, prepare your own appliance definition and build it. It isn't hard to create your own appliances, but please read the how to start page for setting up a building environment, first.
After you create your own appliance definition run this task: rake validate:definitions to be sure that you have valid definitions.
All tasks in JBoss Cloud are Rake tasks. For example, if you want to build and run one instance of your front-end appliance on Amazon EC2, just run: rake appliance:front-end-appliance:ec2:run. This command will build a front-end appliance, bundle to Amazon EC2 format, upload to your bucket, register and launch it!
JBoss Cloud supportJBoss Cloud Support is a subproject of JBoss Cloud that contains all the core functionality for creating appliances.
We decided to move all core functionality to the Support project to make it easier to create projects without having to depend on our specific appliances. This allows you to create your own appliances and package them together with the core functionality.
Future plansThere are several big tasks for the future. We want to do a provisioning and management server that could store ready-to-run appliances. They could be launched on demand or automatically, if the cloud load is big, for example. There is also a need for a management server. At this point there is no way to inject a load balancer address to back-end appliances in some virtualization environments. A management server that is aware of every running appliance could do this automatically.
We have also in plans to create a web application to do management tasks across the whole cloud.
More informationJBoss Cloud is an environment to build and set up clouds of JBoss Application Servers. It's easy to use and provides a fast way to create a fully working cloud.
JBoss Cloud is under heavy development. For more info about JBoss Cloud please refer to the JBoss Cloud home page. The documentation page is also very helpful. Direct news from the JBoss Cloud development team is available via Twitter.
Opinions expressed by DZone contributors are their own.