users@glassfish.java.net

Re: Multiinstance Appliciation architecture and deployment in Gl

From: Tom Mueller <tom.mueller_at_oracle.com>
Date: Fri, 10 Feb 2012 09:12:20 -0600

On 2/10/2012 4:31 AM, forums_at_java.net wrote:
> My 'independency requrements' are:
> I simply need to be able to deploy multiple applications on one Glassfish
> instance and be able to run them in separate Java processes but under the
> same Java virtual machine.
one GlassFish instance == a single Java virtual machine == a single Java
process == a single operating system process

That's how the JVM works. This is true for all Java application servers
(not just GlassFish).
The JVM does support running multiple threads within a single process.

> I need to be able to start/stop each application independently from each
> other.
See the:
asadmin enable
asadmin disable
commands. These start and stop application independently from each other.

> I need to be able reload one application and the other while the othe
> applications should remain active (under IIS this option is called
> 'recycle
> application pool').
See the:
asadmin undeploy
asadmin deploy
commands. These unload and load an application while other applications
remain active.
> In case of a bug in one application, it should not impact on other
> customer
> apps on the same server/instance.
When multiple applications are running in a single instance, and one of the
applications throws an exception due to a bug, other instances are not
impacted.
Here are some cases where the behavior of one application can impact other
applications:
1. Application behavior triggers an appserver bug causing the app server
to crash.
2. Application behavior triggers an operating system bug causing the app
server to crash
3. Application behavior triggers an operating system bug causing the
operating system to crash.
4. Application goes into an infinite loop, thereby starving other
applications from CPU cycles.
5. Application consumes too much memory, thereby starving other
applications from memory.

With case #3 and #4 and maybe with #5, even if you are running
applications in separate instances on the same
operating system, you still have one application impacting another.
> Other applications shoud remain working (of
> course when this bug doesn't spoil entire java vm).
> Is this idea possible to be realized on one Glassfish instance with
> hundred
> applications deployed (enabled on instance/virtual host)?
Whether you can support 100 applications in a single instance depends on
how much
memory you have, how big the applications are, how much traffic the
have, etc. But

> Maybe deploying
> application under different names (like described here:
> home.java.net/node/676678) might be a good solution in my case?
Whether this is applicable depends on the nature of your application.
You didn't mention
whether it is an enterprise app (EAR) or just a web application (WAR).
You can definitely
deploy the same application multiple times with different configurations
using different
names, i.e.,

asadmin deploy --name hello1 --contextroot hello1 apps/helloworld.war
asadmin deploy --name hello2 --contextroot hello2 apps/helloworld.war

If using different virtual servers, the context roots do not have to be
different.

Tom