Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

handling multiple requests for a servlet

 
satya ganesh
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can somebody please explain me how to handle multiple requests for a servlet considering the following scenario,
1. Consider that the web server recieves more requests and the maximum number of threads(configured in xml) running in the server has crossed the limit.
2. consider that each thread will take more than 5 minutes to complete the process.

In the above scenario, whether all other clients requesting the server should wait? or is there way to avoid this apart from clustering and load balancing?
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

2. consider that each thread will take more than 5 minutes to complete the process.

This would not be good design for any web app. Anything over a few seconds response time would have users complaining I think. What is it you do that takes so long? Could you do it asynchronously?


or is there way to avoid this apart from clustering and load balancing?

Long response time aside, if you are hitting the maximum load a servlet container can handle, you would need to look at spreading the load accross more nodes. This would normally mean clustering or load balancing.
 
Amit Ghorpade
Bartender
Posts: 2854
10
Fedora Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi sat gane welcome to Javaranch,
are you sure your application will get that many simultaneous hits so as to cross the thread limit?
If yes then as Paul said, you need load balancing.

Also I think it will be a good idea to minimize the thread time.
 
satya ganesh
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Paul,
Thank you for your reply.. suppose if there is some functionality like uploading some file (that is of huge size). And many users are concurrently uploading file (job sites for instance, where more than hundreds of canditates are uploading their resume concurrently) and the uploads take more time.
In this scenario, can you please throw some light on how the server will do the process?
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The server will process the request in the same way as it would process any request. If there is not a free thread in the thread pool, the client will have to wait. And you would avoid this scenario by performance testing your application with an accepted load, and configuring thread pools/using load balancing as appropriate.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13061
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Consider using Amazon's S3 service to accept the large download traffic. Here is a recent article on a practical application to reduce server traffic. That way you avoid having to invest in any new server hardware.

Your system would then be able to access the files at leisure.

Bill
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic