aspose file tools*
The moose likes Servlets and the fly likes handling multiple requests for a servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "handling multiple requests for a servlet" Watch "handling multiple requests for a servlet" New topic
Author

handling multiple requests for a servlet

satya ganesh
Greenhorn

Joined: Jul 14, 2008
Posts: 7
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

Joined: Apr 14, 2004
Posts: 10336


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.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Amit Ghorpade
Bartender

Joined: Jun 06, 2007
Posts: 2718
    
    6

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.


SCJP, SCWCD.
|Asking Good Questions|
satya ganesh
Greenhorn

Joined: Jul 14, 2008
Posts: 7
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

Joined: Apr 14, 2004
Posts: 10336

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

Joined: Mar 22, 2000
Posts: 12835
    
    5
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: handling multiple requests for a servlet