Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Servlet handling multiple clients request

 
Pashi Soni
Greenhorn
Posts: 26
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How do Servlet handles request from multiple clients at one time. Suppose there are 100 users requesting servlet service, then will not the performance decrease if one instance of servlet will handle all request. How do we create multiple instance of servlet ?
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13048
6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You don't create multiple instances of servlet. The servlet engine creates a separate Thread for each request (up to some max number of Thread)
The performance is related to the number of Threads, not the number of instances of the servlet.
Bill
 
Pashi Soni
Greenhorn
Posts: 26
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yeah William, I agree to you. If there are 1000 request , and the maximum threads that can be generated by servlet is 100, then there will be performance degradation. How to over come this. Is there any another method to handle so many request without performance issue ?
 
Matthew Vincent
Greenhorn
Posts: 8
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can deal with this type of issue using a load balancer such as a Big IP. The idea is to have multiple servers behind the load balancer that can handle the same request. The load balancer should be configured to "route" the requests to any one of the servers based upon different parameters/settings (round robin distribution, load distribution, etc.). The more load you need, the more servers you should add. However, this does send all traffic through the load balancer so it is important that this be redundant and failover safe.
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I remember working with MS IIS that there was a thread pool of configurable size. Each request that comes in is serviced on a thread from the pool. When there are more requests than threads, requests go into a queue. When the queue reaches a certain depth, the server returns a "Server busy" error and throws the request away.
Does J2EE specify strategies like this? Are most implementations pretty similar to that?
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13048
6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In Tomcat - server.xml - you have the maxProcessors and acceptCount attributes

According to Professional Apache Tomcat (good book), these are the parameters you tweak to adjust responsiveness to large loads.
Bill
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic