I have one WAR ( app.war ) and one container ( Tomcat, Jetty, Glassfish, whatever ). My goal is to deploy, on demand, hundreds of instances of this same web application on the container.
http://foo/app1 --> app.war
http://foo/app2 --> app.war
http://foo/app3 --> app.war
...
http://foo/appN --> app.war
Some obvious ways of achieving this:
- In Tomcat, create one context.xml file for each app ( named appN.xml ), all pointing to the same WAR. Other containers have similar methods
- Problem with this approach: It will explode the WAR N times, taking up a lot of disk space
- Use symbolic links to create webapp/{app1,app2,appN} folders pointing to an exploded version of app.war. This prevents the disk space explosion, but the JVM is still loading many duplicate JARs to memory
- Use some shared lib folder to contain most jars ( and a combination of the previous two options ).
I wonder if there is a better method to do this. Ideally, creating a new instance should not take up ANY more disk space ( other than marginal configuration files ) and only take up memory related to thread execution stacks and other runtime allocations.
Any ideas?