I've got a web application our vendor has mentioned must respond within 2.5 seconds and become functional within 3 seconds.
At this time it's mainly POJOs on the top of the very finely sliced Spring MVC layer that is getting used for dependency injection and pointing demands to remotes.
The webapp is an extremely thin slice of meat between a collection of APIs that are being created to provide cohesion to some disparate group of early, irregular APIs. Most of which may take more than 3 seconds (though much less frequently)
Things I want is a method to tell spring or tomcat when it is not loading the JSP by within 2500ms I wish to load the jsp that informs our user that "Dude, we are crawlin' through molasses here! Provide us with another and check out again. When you get this site multiple occasions then you are really boned!"
At this time it seems I possibly could do that a number of ways (purchased by my desire)
- In spring I might have the ability to setup a timeout and load another jsp
- Within the load balancer I might have the ability to setup a timeout having a redirect
- In tomcat I might have the ability to setup a timeout and load another jsp
- In apache I might have the ability to setup a tomcat iwth a redirect
- within the application I split the architecture to operate in the thread that's questioned every 100ms to ascertain if it had stopped running, and after 2500ms it throws the best
Basically remember properly, all demands to Spring MVC go using a single filter. You are able to most likely override it and program your timeout configurations (e.g. possess a configurable XML with timeout-enforced Web addresses or pathways). Guava's TimeLimiter will be a good tool to implement the timeout enforcement itself.
I'm not sure the you are in, but generally within the web world it's a little too self-demanding to stress if your response does not return by 50 percent-3s, particularly if lengthy taking reactions are only a minority (while you say). I've knowledge about large heaps (Xmx=10g) where only a GC may take several minutes to complete. OK, maybe it is really an overrated example, only one-two second taking GCs are pretty reasonable.
Even Tomcat manual states that really small timeouts will probably be detrimental. Your products owner should be choleric :)
Ah, there's more. Remember you cannot just redirect for those who have already published something to your servlet response. Which means you most likely have to delay your response before the last little bit of computation is performed and flush everything in the finish. Which means you need to wrap your
HttpServletResponse having a decorator that has some kind of a latch which delays response output before the full fact is produced, or maybe timeout happens - redirects to "ouch" page.