• Post Reply Bookmark Topic Watch Topic
  • New Topic

Servlet Container  RSS feed

 
Gregor Joseph
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
How does the Servlet Container handle multiple requests at a time?For instance
if you have a website and that website is accessed by 50 users.How does the Servlet container handle this situtation?

Thanks in Advance

GJ
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A new thread is created for each request.

The beginning of the servlet spec does a pretty good job of explaning this.
There is a link in my signature.
 
Bruce Jin
Ranch Hand
Posts: 672
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there a limitation as how many threads can be created at the same time?
Thanks
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
 
Jeroen Wenting
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
there is a limit. Each thread takes up memory and CPU resources and at some point those will run out.
But by the time you get to that point you're looking at many more reasons for buying more server hardware so it shouldn't be a problem.
 
Gregor Joseph
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the solution.But I had a different question related to this.Does a Single Threaded Model help in preventing a Servlet from Handling Multiple requests at a time?

Thanks
GJ
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nope, I believe that considering single thread model in this context is a mistake. STM ensures a servlet instance will only be accessed by a single thread at a time, but it does not say anything about the number of instances of this or any other servlet.
 
vu lee
Ranch Hand
Posts: 208
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I believe the new version of servlet does not support single thread model. The web server accepts up to a limit number of http connnections. In this case, the number of servlet threads cannot exceed this limit.
 
Sharad Agarwal
Ranch Hand
Posts: 167
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Gregor Joseph:
Does a Single Threaded Model help in preventing a Servlet from Handling Multiple requests at a time?


Out of curiosity, why would you want to limit the number of concurrent requests to one? Or, for that matter, to any defined number?

If there is a strong business reason, I suppose you could implement it with a synchronized token in your servlet.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Limiting the number of concurrent requests can be handled in Tomcat with configuration parameters (see the link in Ben's post) - presumably other servlet containers have similar methods.
SingleThreadModel is still in the API as of 2.4 but is deprecated for very good reasons.
Bill
 
Sharad Agarwal
Ranch Hand
Posts: 167
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by William Brogden:
Limiting the number of concurrent requests can be handled in Tomcat with configuration parameters (see the link in Ben's post) - presumably other servlet containers have similar methods.


To run off on a tangent, what is the general consensus on using non-standard container specific features? Does that not lead to vendor tie-in? Or is it that the add-on features are usually valuable enough that it is worth the loss in portability?
 
veron khalil
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i think you whould vrify the link
 
kumarbobby
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
this is vinay according to myself if the container get any request from the client it automatically starts a new thread but not new instance of the servlet. so the container manage the multiple requests like this
 
D Rog
Ranch Hand
Posts: 472
Linux Objective C Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've implemented single thread model in some servlet container. Actually it worked fine. Regarding number of concurrent threads, I believe socket backlog parameter will be actual limmitation.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Sharad Agarwal:


To run off on a tangent, what is the general consensus on using non-standard container specific features? Does that not lead to vendor tie-in? Or is it that the add-on features are usually valuable enough that it is worth the loss in portability?


If this was a setting in web.xml that violated the spec or was 'extra-spec' I'd be dead set against it (Resin has a few of these). In this case, like JVM switches it has more to do with environmental issues and doesn't encourage apps to be written in a non-spec way that would limit their portability.

As Mr. Brogden stated, It's probably a common feature in other containers. I haven't used enough to say.
 
Sharad Agarwal
Ranch Hand
Posts: 167
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ben Souther:


If this was a setting in web.xml that violated the spec or was 'extra-spec' I'd be dead set against it (Resin has a few of these). In this case, like JVM switches it has more to do with environmental issues and doesn't encourage apps to be written in a non-spec way that would limit their portability.

As Mr. Brogden stated, It's probably a common feature in other containers. I haven't used enough to say.


Thanks Ben. I like this neat delineation of what is acceptable and what is not.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!