Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

distributable

 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have come accross this word number of times and I would like to clarify what I am thinking.
So if my web application is distributable(say in 2 machines)
machine1
webapp
shan
webinf
similarly in machine 2 I have the same directory structure. ie
webapp
shan
web-inf
am I correct??? is this what is distributable ???
 
Peter den Haan
author
Ranch Hand
Posts: 3252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Distributable" refers to the ability to run a single servlet container on multiple JVMs and even multiple machines. This gives you better scalability (just add more machines) and failover (if a machine dies, the others can take over).
The crucial difference between a distributed container and just running multiple ordinary containers is that a distributed container will have some mechanism to share HTTP sessions between the machines. For example, it may serialize the session and store it into a shared database.
I said "serialize". This is an important point in a distributable web application. When you mark a web-app as "distributable", all objects you store in the HttpSession must be serializable. Otherwise, the container can't do its distribution magic. You must also not use any techniques that break in a distributed container; for example, any instance of the Singleton pattern is potentially suspect as each JVM will get its own copy of the "Singleton". Well, most attempts at implementing Singletons in web containers are broken anyway, with class reloading and all that.
- Peter
 
Tariq Dweik
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all
can anyone give an example on how to setup a distributable webapp in tomcat
Thanks in advance
 
R K Singh
Ranch Hand
Posts: 5384
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Peter den Haan:

- Peter

Thanks Peter
 
Jim Bertorelli
Ranch Hand
Posts: 136
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just one minor correction to what Peter said. Sessions are not actually shared accross multiple JVMs. They can, however, be moved across multiple JVMs.
The point is, an HttpSession will be available only on one JVM at a time (so no sharing since only one JVM has exclusive access to the session). And all the requests belonging to that session will be serviced by that JVM. In case of failover or load balancing, the clustor manager can "move" this session to another server.
This is in contrast with the non-default servlet contexts, where each JVM has it's own copy of the the ServletContext. In this case also there is no sharing because each JVM has exclusive access to it's own copy.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic