File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes Servlet handling multiple clients request Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Servlet handling multiple clients request" Watch "Servlet handling multiple clients request" New topic
Author

Servlet handling multiple clients request

Pashi Soni
Greenhorn

Joined: Feb 27, 2003
Posts: 26
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

Joined: Mar 22, 2000
Posts: 12835
    
    5
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

Joined: Feb 27, 2003
Posts: 26
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

Joined: May 01, 2003
Posts: 8
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

Joined: Jan 29, 2003
Posts: 8791
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?


A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12835
    
    5
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
 
 
subject: Servlet handling multiple clients request