• 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
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

Requests to Servlets

 
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?

Thanks a lot.
DG
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Nupur Gupta
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks a lot. For a particular servlet instance, is there a limit on the number of client requests it can face?
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't think that the servlet in itself has a particular limit.
 
Sheriff
Posts: 67682
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
Nupur Gupta
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

Thanks a lot.
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes,
See the maxThreads attribute on this page (For Tomcat):
http://tomcat.apache.org/tomcat-5.5-doc/config/http.html

I'm not sure how other containers handle this.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Bear Bibeault
Sheriff
Posts: 67682
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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 will suppress my every urge. But not this shameless plug:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic