Hobione's Weblog

Living & Breathing in Web 2.0 Era

Glassfish Virtual Server

Scenario: We are running Glassfish on our production server as the default mode.  Here is a screen shot for the default serve.

Glassfish default server

Glassfish default server

The ip for the server, 111.25.000.69 which alias to http://abc.amc.xxx.info and Default Web Module is “Root” app.

Dilemma: We wanted to set up a virtual server for a new URL, http://idms.abc.xxx.info and register the Default Web Module to ” iDMSCommingsoon” app.

How the world can we do that?  We are not running any Appache on top of Glassfish,  is Glassfish smart enough to figure it out which application to respond based on URL, etc.  The answer is YES. It is so easy to set that up by using Glassfish admin tool.

Solutions:  Here are few choices I had, were recommended by Sun’s Technician:
“I’m sure you know this, but it bears mention now. A combo of IP+Port number can have only one process/program binding to it… thus if you have 1 IP address, any port there, can be “used/bound to” only once. This is true for all Web or App Servers or any Server for that matter.

The SJAS/Glassfish, works around this limitation by using the concept of Listeners and Virtual Servers.
A Listener can be instructed to listen/respond to different domains (web domains, not App Server domains) such as www.aaa.com and www.bbb.com
You can then have and configure your Virtual Servers to use those listeners.

Couple of scenarios you could approach.
-If you have available more IP addresses, you can create another listener, assign it to use Port 80 and create your Virtual Servers to use it.
Or
-If you have only one IP available, you can modify existing listener to also respond to new site (idms.faa.gov) and configure the new Virtual Server to use
the same listener.

Either way, DNS will need to be modified accordingly, whether you point 1 domain (HTTP domain, not App Server domain) to that IP or have 2 or more domains pointing to that IP (absolutely possible).

More about it can be seen here:
http://docs.sun.com/app/docs/doc/819-3671/ablsw?a=view”

This is how we have tackled this issue initially:
1. We have aliased http://idms.amc.xxx.gov to the same ip 112.25.000.69 as the other URL has been using for years.
2. We have changed few things on setting as follows.

Virtual Server Setup

Virtual Server Setup

You may notice that idms Virtual Server is using the same Listeners for other server, so they are sharing listeners.

3. Here is the same old way to deploy a .war but only thing I have changed is server name.

Deploy app on a Virtual Serve

Deploy app on a Virtual Serve

What a surprise, it worked!
Here is my lame drawing to show the big picture.

Concern: I have a concern about performance.   Since both URLs are using same ip and listeners, what are chances for the bottleneck when both URLs starting get many hits simultaneously.

Here what expert said: Since there are two services/sites/hostnames using one resource, yes, it could become an issue…however  monitoring, testing, baselining and tuning are always recommended, in that respect the following should hopefully help:
http://docs.sun.com/app/docs/doc/819-3681

specifically, these two should help, but the entire Tuning Guide is a good read:

http://docs.sun.com/app/docs/doc/819-3681/abedw?a=view
http://docs.sun.com/app/docs/doc/819-3681/abefk?a=view (See Req processing and Keep Alive).

Hope information helps.

October 2, 2008 Posted by HobiOne | GlassFish | | 4 Comments