• Post Reply Bookmark Topic Watch Topic
  • New Topic

is my understanding correct.

 
vishwa raj
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have gone through some of the posts and understood below concept.

1. In SingleThreadModel for every new request separate instance of servlet will be created and request will be serviced once completed instance will be destroyed for performance improvement some vendors pool the servlet insatnces and reuse the instance to provide service. However those information at application level like session and other shared resources will be still shared by two threads using two separate instances of servlets.

2. In multi threaded environment there will be only one insatnce of the servlet and for each request new thread will be created but all the threads will access same single insatnce of servlet. However when the load is too heavy on the instance container can create new instnce for performance improvement.

Is my understanding correct.

Thanks
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No problems with #1

In #2 there is no performance gain in providing more servlet instances, but it does use a thread pool to prevent having to create threads
 
vishwa raj
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the reply,

can you Please explain me about #2 you are trying to tell.

Thanks
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by vishwa raj:
However when the load is too heavy on the instance container can create new instnce for performance improvement.


This part is false.
Look at SRV.2.2 in the servlet spec (link in my signature):

SRV.2.2 Number of Instances

The servlet declaration which is part of the deployment descriptor of theWeb application
containing the servlet, as described in Chapter SRV.13, �Deployment
Descriptor�, controls how the servlet container provides instances of the servlet.
For a servlet not hosted in a distributed environment (the default), the servlet
container must use only one instance per servlet declaration. However, for a servlet
implementing the SingleThreadModel interface, the servlet container may
instantiate multiple instances to handle a heavy request load and serialize requests
to a particular instance.


Containers (as David mentioned) may pool the threads that access your servlet but not the servlet itself.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!