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 can we have more than one instance of a servlet at container start up 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 "can we have more than one instance of a servlet at container start up" Watch "can we have more than one instance of a servlet at container start up" New topic
Author

can we have more than one instance of a servlet at container start up

Bis Bang
Greenhorn

Joined: Jan 28, 2004
Posts: 15
Hi gyes.. I have a little doubt...
As the life cycle of servlets says that the container will create one instance per servlet at startup or when the 1st request comes up for the servlet. If other requests come in by that time the container will see if there is any intance of that servlet is existing if its there than a new thread will be processing the second request.. and same for other request also.. Now if my servlet is to be designed to handle 1000 request at a time.. will there be 1000 therads processing the request on behalf of Only single instance of that servlet or we can have different concept to do that..(as far as i know instance pooling is available only for the servlet which implements Single Thread Model)...
Thanx in advance....
Bish
[ March 01, 2004: Message edited by: Bis Bang ]

The glory lies not in not falling, but it lies in rising everytime you fall
Frank Carver
Sheriff

Joined: Jan 07, 1999
Posts: 6920
Yes, there would be 1000 threads running through a single servlet at the same time, but this is a good thing! Think how quickly your server would run out of memory, if there was a separate servlet for each request.
It's a common misunderstanding, but believe me, you don't need separate instances to make your application go faster. Each thread only needs to read the servlet code, and lots of threads can be reading the same code at the same time.
An anology I have used before is that of a movie theater. You don't expect the movie to take longer just because a few more people come in to see it today.
Does that make sense?


Read about me at frankcarver.me ~ Raspberry Alpha Omega ~ Frank's Punchbarrel Blog
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: can we have more than one instance of a servlet at container start up
 
Similar Threads
can same servlet have multiple instance in container
Can we control number of threads of a servlet instance
Multiple requests to a servlet
Single Thread Model.
How servlet process multiple request.