Can we set a timeout for servlet execution time, eg. 2000ms, if the servlet takes more than 2000ms to finish execution, the container should interrupt it and call interrupt() method to allow some clean-ups. I think this feature could improve system stability if I already know most pages' latency is under 1000ms.
Please join the discussion if you have any ideas.
This feature could be an optional feature, not a full time feature, because the servlet may be doing some work, processing some IO and it may not complete in 2000ms and killing such a servlet may not be very helpful. However implementing a specific interface for special kinds of requirement may be a good thing, if we fix that under what ever condition, we need to finish the work within 2000ms else we will not use process at all. However this would mean that there has to be a monitor thread which keeps tracks of the time a servlet spends and then destroy it and then call the garbage collector. There has to be some changes in the way the application server handles the resource pool of threads and how it maintains and handles the servlet object.