You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by John Shilling <jj...@gmail.com> on 2008/11/19 20:13:09 UTC

Re: Supporting Large Number of Web Application Instances

I am looking at having to support tens or even hundres of instances of our
web application in an ASP Model.  We use Tomcat as our application server
and it seems to me that three possibilities as a base model for each
physical server

1.  Have a single Tomcat instance per server with multiple virtual hosts
2.  Have multiple Tomcat instances on a single OS instance and host one web
app per Tomcat instance
3.  User virtual servers to host one Tomcat Instance per Virtual OS and host
one web app per Tomcat instance.

As you go down the stack it seems you use more resources per app instance
but get more isolation.

This is really like an SMP at the application level but each application
instance will connect to a distinct database (this is a domain where
crossing the beams would be bad).

Do people really do option #1 in a production environment?  I can figure out
how to set up realms for initialization parameters but it is still a single
class namespace within the Tomcat container, right?  It seems that special
care must be taken with singleton objects (such as the Hibernate Session
Factory) so make sure that they are managed in the context of their Virtual
Host/App Instance.

Are there established practices for doing #1?

Thanks,
John

Re: Supporting Large Number of Web Application Instances

Posted by David Wall <d....@computer.org>.
John Shilling wrote:
> I am looking at having to support tens or even hundres of instances of our
> web application in an ASP Model.  
We basically do this now using a single Tomcat instance with multiple 
webapps (https://host.com/App1/, https//host.com/App2/ etc....) and 
don't use virtual servers because we use SSL, and to make that work, 
you'd need multiple IP addresses, multiple keystores and multiple SSL 
certs.  In our model, that's not a requirement.

We're only doing about 50 webapps per Tomcat now, so whether it could do 
hundreds, is hard to say.  Also, obviously, it depends on the 
networking, memory, processor and disk capabilities to support all of 
those.  I mean, if one webapp is doing millions of transactions per day, 
you may find few servers that could handle lots of those together, and 
if one is transferring lots of data in and out, it could hog up 
bandwidth, etc.  And of course one webapps usage will impact the 
performance of others, so you'll probably need to balance webapps as you 
scale up.

Each of our webapps can run different versions of our base software, but 
as mentioned before, they all must run on the same version of Tomcat and 
Java -- and in and our case, the same version of the backend PostgreSQL 
database which hosts a database per webapp. 

It's worked well for us so far.

David


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Supporting Large Number of Web Application Instances

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

John,

John Shilling wrote:
> Do people really do option #1 in a production environment?

Sure.

> I can figure out how to set up realms for initialization parameters
> but it is still a single class namespace within the Tomcat container,
> right?

Not really. One of the container's jobs is to isolate webapps from each
other so they don't interfere.

> It seems that special care must be taken with singleton objects (such
> as the Hibernate Session Factory) so make sure that they are managed
> in the context of their Virtual Host/App Instance.

Yes. Each webapp gets its own ClassLoader which loads classes from that
webapp's WEB-INF/lib/*.jar files. Assuming that your webapps are
self-contained, even singletons should operate correctly "alongside"
each other in different webapps. I'm not expert at Tomcat internal
workings, but I expect that the level of isolation between two webapps
in the same Virtual Host is the same as the level of isolation between
two webapps in different Virtual Hosts.

> Are there established practices for doing #1?

Do not put any libraries in the server's shared class loaders unless
it's okay that they actually be shared. For instance, don't shove
Hibernate's JAR in there so you can save a little memory by sharing the
classes. If you do that, you've "crossed the streams" so to speak.

The main thing I would be worried about is the apps stealing time from
each other. There's not a whole lot you can do about that except get
more hardware. There's also the possibility of upgrades and such. do you
want to be able to run some clients/customers on different versions of
your application that require different JVMs, for instance? It should be
obvious that a Tomcat instance must run on only one JVM at a time ;)

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkkkcdkACgkQ9CaO5/Lv0PA89QCgjkZxgWiQTi/9tAN0WiiDpKoF
pCgAn06jbdr4DDysNXNfLoK8uRP9DqLm
=fOpP
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org