File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes Number of Servlet Instances Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Number of Servlet Instances" Watch "Number of Servlet Instances" New topic
Author

Number of Servlet Instances

rahul dighe
Ranch Hand

Joined: Apr 17, 2001
Posts: 44
Hi,
Excerpt taken from Servlet spec 2.3 . question below
For a servlet not hosted in a distributed environment (the default), the servlet
container must use only one instance per servlet declaration
.
In the case where a servlet was deployed as part of an application marked in the deployment descriptor as distributable, a container may have only one instance per servlet declaration per virtual machine (VM).
I do not understand the difference between a servlet marked distributalble and the default(which is not distributable) in the context of number of servlet instances.
to sum it up
Not Distributable - 1 instance
Distributable - 1 instance/vm
whats the difference between one instance and one instance/vm, it sounds the same to me.


<BR>Rahul Dighe
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

It is the same, *IF* you are talking about a single instance of your web container. (marking something 'distributable' in a single-container environment has no effect).

Imagine for a moment that you are writing an application that will never run anywhere but your local box. Or your one single web server in your hosting company's data center. This is the case you are thinking of. This is the case where it makes no difference.

But what if you wrote an application that was for 'enterprise' and needed redundancy. Or what if it was to serve a site as huge as www.cnet.com or slashdot. You'd need scalability.

The way we do these kinds of things is by using more than one web container, and having these multiple containers share the load.

Assume two containers: In this case there is a big difference between "one instance" and "one instance per vm". The spec states that while there may be two instances of the servlet (by virtue of there being two containers)... there is still only one PER container.

However, I just saw what is a potentially confusing point in the spec. 'Container' in my mind usually equates to a single VM. If there are two instances of the container, that's two VM's. But the spec doesn't implicitly limit a container to a single VM. The point here is, that for some 'enterprise' level systems, there might be a fuzzy boundary between what a 'container' is and what a VM is. eg: iPlanet's kas/kxs process might be a 'container' that contains two VM's (called kjs processes).

The thing to remember is "one instance per VM only and always"

And of course, this entire discussion only applies to those servlets that don't implement SingleThreaded model.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Number of Servlet Instances
 
Similar Threads
Servlet Lifttime
Servlet instances
total servlet instance in distributable enviornment
servlet pool
Requests to Servlets