• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Sheriff
Posts: 7001
6
Eclipse IDE Python C++ Debian Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic