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 ?
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
Joined: Feb 27, 2003
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 ?
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.
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
Author and all-around good cowpoke
Joined: Mar 22, 2000
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