I have an issue with cached requests in Tomcat. Whenever I (re-)start my application, Tomcat begins caching incoming request before the application is fully initialized.
Is there a way to stop Tomcat behaving like this? I found the "cachingAllowed" option in the -Element, but I am not sure about this.
Can you please advise on, how to prevent Tomcat from caching before everything is initialized. The point I would expect requests to be cached is when the server startup is complete.
Many Thanks,
Marc
The effect you are describing is called request queuing. By default Tomcat starts and listens to its configured port. When the first request comes in, it triggers that the corresponding web application is deployed and started. All requests that come in before the application is started are blocked and processing starts when the application startup is done.
The above description is a little simplified, because depending on your Tomcat connector type and configuration there are different areas where requests can blocked and queued up:
maxThreads
.maxConnections
.acceptCount
. (BTW: I set this to 0)As said, how the parameters work in detail may vary by connector type.
This is how you can control the limits and for the understanding what is going on. I think your effect will get better with setting acceptCount to 0.
Actually, the same problem and question was asked in: how to make http port to open after application startup in tomcat No real answer there, also. It seams this is not how Tomcat is designed to work. Solutions I can think of, but not yet tried myself: