防止Tomcat在启动期间缓存请求 [英] Prevent Tomcat from caching request during starup

查看:201
本文介绍了防止Tomcat在启动期间缓存请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Tomcat中缓存的请求有问题。每当我(重新)启动应用程序时,Tomcat都会在应用程序完全初始化之前开始缓存传入的请求。

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.

是否有一种方法可以阻止Tomcat像这样进行操作?我在-Element中找到了 cachingAllowed选项,但是对此我不确定。

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.

能否请您提出建议,如何防止Tomcat在一切就绪之前进行缓存初始化。我希望可以缓存请求的时间是服务器启动完成后。

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.

非常感谢,

Marc

推荐答案

您描述的效果称为请求排队。默认情况下,Tomcat启动并监听其配置的端口。当第一个请求进入时,它触发相应的Web应用程序已部署并启动。

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.

上面的描述有些简化,因为取决于您的Tomcat。连接器类型和配置在不同的区域可以阻止和排队请求:

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

  • 操作系统接受传入的TCP连接,但Tomcat尚未处理。这由 acceptCount 控制。 (顺便说一句:我将其设置为0)

  • A processing thread waits for the application to start. The limit is controlled by maxThreads.
  • A request waits for a processing thread. The limit is controlled by maxConnections.
  • An incoming TCP connection is accepted by the operating system but not yet handled by Tomcat. This is controlled by acceptCount. (BTW: I set this to 0)

如前所述,参数的详细工作方式可能因连接器类型而异。

As said, how the parameters work in detail may vary by connector type.

这是您可以控制限制并了解发生了什么的方式。我认为将acceptCount设置为0会更好。

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.

实际上,在如何在tomcat中启动应用程序后打开http端口没有真正的答案还有。它表明这不是Tomcat设计的工作方式。我能想到但尚未尝试过的解决方案:

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:


  • 找到一种使用禁用的连接器启动Tomcat的方法(我没有找到用于……),并在JMX启动后启用它。

  • 切换到嵌入式Tomcat或Jetty,该应用程序从应用程序启动

这篇关于防止Tomcat在启动期间缓存请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆