This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Hi, At a particular server, when a servlet is instantiated, do multiple clients access the same instance? Or is it recreated for each client? Maximum how many clients can access a particular servlet at one time? Can this be pre-defined?
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. 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 Java Virtual Machine (JVMTM). However, if the servlet in a distributable application implements the SingleThreadModel interface, the container may instantiate multiple instances of that servlet in each JVM of the container.
Originally posted by Nupur Gupta: For a particular servlet instance, is there a limit on the number of client requests it can face?
No. And what would be the point? Either the servlet is multi-threaded or it's not. If a servlet can handle two simultaneous requests, it can handle any number. The limitation is on the number of threads a server can support.
And, SingleThreadModel is deprecated and should never be used.
Thanks a lot, Bear and Satou. Am requesting a clarification - so does a server have a pre-defined number of threads it can handle at a particular time? I guess this is like number of threads any machine can handle... perhaps threads just have to wait in queue until resources are available. But perhaps it can be pre-defined at the app server level.
The number of servlets the server can handle at one time is server dependent and most of the servers provide good performance. However i am not sure whether we can specify the number of servlets(threads) a server can handle in anyway. And the same servlet instance can be accessed by multiple requests(not matter what the number is) unless it implements the SingleThreadModel interface.
Originally posted by Murari Baikady: The number of servlets the server can handle at one time is server dependent and most of the servers provide good performance. However i am not sure whether we can specify the number of servlets(threads) a server can handle in anyway.
In the previous reply, it was shown how this can be done for Tomcat. Other servers may have similar settings.
And the same servlet instance can be accessed by multiple requests(not matter what the number is) unless it implements the SingleThreadModel interface.
Which, as was also pointed out in a previous reply, is deprected and should never be used.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com