简体   繁体   English

CLOSE_WAIT连接的Tomcat行为

[英]Tomcat behavior for CLOSE_WAIT connections

The acceptCount queue is maintained at OS level. acceptCount队列在操作系统级别维护。 Lets say we have a acceptCount queue of 10K. 假设我们有一个10K的acceptCount队列。

Situation - The server is unable to process the request or is taking a long time due to one of the dependencies or network issue and during the time all the clients timeout. 状况-服务器由于依赖关系或网络问题之一而无法处理请求,或者花费了很长时间,并且在此期间所有客户端都超时。 Eventually the queue has 10K CLOSE_WAIT connections. 最终,该队列具有10,000个CLOSE_WAIT连接。 Now if the service is backup again and start processing. 现在,如果服务已再次备份并开始处理。 Would it clean up the CLOSE_WAIT connection queue? 会清理CLOSE_WAIT连接队列吗? How will tomcat behave in such situation. 在这种情况下,tomcat将如何表现。

a few tips about CLOSE_WAITS and reaching max connections/thread count, (I had similar problems in WebLogic server, but these are general tips) 有关CLOSE_WAITS并达到最大连接数/线程数的一些技巧(我在WebLogic服务器中也遇到类似的问题,但这是常规技巧)

to release stuck threads due to network issues: (if allowed according to the business) 由于网络问题而释放卡住的线程:(如果根据业务允许)

  1. set timeout value to all remote calls (eg DB/ HTTP/ EJB/..) 将超时值设置为所有远程调用(例如,DB / HTTP / EJB / ..)
  2. check for Terminating/Killing long running threads (requests) 检查终止/杀死长时间运行的线程(请求)

better check closely and get to the root-cause, before trying any workarounds. 在尝试任何解决方法之前,最好仔细检查并找出根本原因。

CLOSE_WAITS should clear after heavy-load period is over in case this is the issue, but in case of stuck threads you might need a restart ASAP to solve the issue. 如果这是问题所在,则应在重负载周期结束后清除CLOSE_WAITS,但如果线程阻塞,则可能需要尽快重新启动以解决问题。

The acceptCount queue is maintained at OS level. acceptCount队列在操作系统级别维护。

By this I assume you mean the listen backlog queue. 我假设您的意思是侦听积压队列。

Let's say we have an acceptCount queue of 10k. 假设我们有一个10k的acceptCount队列。

There is no way to tell. 没有办法告诉。 You can hint to the operating system how long you would like it to be, but the operating system can adjust it both up and down, and there is no API to tell you what the actual length is. 您可以向操作系统提示您希望使用多长时间,但是操作系统可以上下调整它,并且没有API可以告诉您实际长度是多少。

Eventually the queue has 10k CLOSE_WAIT connections. 最终,该队列具有10k CLOSE_WAIT连接。

No it doesn't. 不,不是。 CLOSE_WAIT states are not queued anywhere, and the listen backlog queue has nothing to do with CLOSE_WAIT whatsoever. CLOSE_WAIT状态不会在任何地方排队,并且监听积压队列与CLOSE_WAIT无关。

Would it clean up the CLOSE_WAIT queue? 会清理CLOSE_WAIT队列吗?

There is no such queue to clean up. 没有这样的队列可以清理。

If what you are really asking is would restarting the process clear all the ports in CLOSE_WAIT state, the answer is that exiting the process which held them would do that. 如果您真正要问的是重新启动进程,请清除所有处于CLOSE_WAIT状态的端口 ,答案是退出保留它们的进程即可。

However so does letting Tomcat detect all the closed connections and close them itself. 但是,让Tomcat检测所有关闭的连接并自行关闭它们也是如此。 If you have lots of these, the real issue is why it isn't doing that automatically. 如果您有很多这些,那么真正的问题就是为什么它不会自动执行此操作。 It should. 这应该。

If this is caused by one request being forwarded somewhere, it sounds like something is synchronized internally that shouldn't be synchronized, in your application. 如果这是由一个请求转发到某个地方引起的,这听起来像是您的应用程序内部进行了同步,而不应该同步。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM