Tomcat在Spring Boot中的线程卡住检测

huangapple go评论64阅读模式
英文:

Tomcat stuck thread detection in spring boot

问题

Tomcat文档提供了通过启用thresholdinterruptThreadThreshold来处理卡住的线程的配置。

https://tomcat.apache.org/tomcat-8.0-doc/config/valve.html#Stuck_Thread_Detection_Valve

我已经在Spring Boot 2.x.x中启用了它,用于嵌入式Tomcat的基于Bean的配置,并成功实现了它。如果线程超过阈值,它能够终止线程。

我想知道启用它的缺点是什么。目前我没有找到有关最佳实践的文档。

任何帮助都将不胜感激。

英文:

Tomcat document provided configuration to handle stuck thread by enabling
threshold and interruptThreadThreshold subsequently.

https://tomcat.apache.org/tomcat-8.0-doc/config/valve.html#Stuck_Thread_Detection_Valve

I have enabled it in spring boot 2.x.x for embedded tomcat using bean based configuration and achieved it. It is able to kill thread if it is exceeding threshold.

I am looking for what is cons for enabling it. As of now i did not get any docs about best practices.

Any help would be appreciable.

答案1

得分: 2

你应该真正问自己为什么需要配置这个设置。通常主要原因是为了防止在生产环境中资源耗尽。但这只是一种缓解措施,而不是解决方案。每次终止线程都意味着某个任务未完成,存在数据损坏的潜在风险。最佳做法应该是分析为什么线程花费太多时间,并在可能的情况下修复它。

英文:

You should really ask yourself why do you need to configure this setting. The main reason usually is to prevent resource exhaustion in a production environment. But this is a mitigation, not a solution. Every time a thread is killed it means some task has not been completed, and there is potential for data corruption. The best practice should be to analyze why a thread is taken too much time and fix it whenever possible.

huangapple
  • 本文由 发表于 2023年6月2日 02:09:18
  • 转载请务必保留本文链接:https://go.coder-hub.com/76384599.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定