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 http://www.aaa.com and http://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.

About these ads

October 2, 2008 - Posted by | GlassFish |

6 Comments »

  1. Dear Hobione

    This is the good documentation, Now i can mange one web application one glassfish virtual server thank for that and i am glad this doc,

    but i have another problem when i going to host two web site on glassfish that mean i have to domain name ( http://www.abc.com, and http://www.bcd.com and to .war file abc.war, bcd.war) then i have created two virtual servers for that domain names and one http listener port for port 80 , then i type URL (www.abc.com or http://www.bcd.com)the same url refer one web module (abc.war)

    please is there any documentation for host multiple web hosting on glassfish send to your blog

    Thank

    Best regards

    nilanga

    Comment by Nilanga | April 11, 2009 | Reply

  2. Hi,

    What profile you use for the Virtual Server, because i use developer profile and have not http listeners and virtual servers

    SaludOS

    Comment by lyonn | April 19, 2009 | Reply

    • We are using Sun Java System Application Server 9.1, Update 2

      Comment by HobiOne | April 19, 2009 | Reply

  3. Hi HobiOne,

    Sorry for taking so long to reply. I’m on holiday right now with limited access to the internet.

    HobiOne, I think I’m as thick as they come lol; After your comments I gave it another go but I’m still unable to get it to work for me.

    May I ask if you could have a look at the list of steps in my last posting to confirm i’m doing things right.

    Thanking you in advance
    J
    May the force of Java be with you!

    Comment by J Marks | May 22, 2009 | Reply

  4. I am using Java EE 6 with GF 3.0.1. How can I configure so that my web addr is http://www.myhost.com instead of http://www.myhost.com:8080/myproject-war. Please help.

    Comment by Thang Pham | January 6, 2011 | Reply

    • Deploy web-application in root “/”. Change port of http-listener from 8080 to 80.

      Comment by TokiTori | August 1, 2011 | Reply


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: