• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Servlet handling multiple clients request

 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ?
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ?
 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
reply
    Bookmark Topic Watch Topic
  • New Topic