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?
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.
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?
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.
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.