负载下降后线程仍然存在 [英] go threads sticking around after the load goes down

查看:55
本文介绍了负载下降后线程仍然存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有基于反向代理的服务器.当我监控应用程序的指标时(使用 prometheus),我注意到当应用程序的负载上升时,应用程序上的线程(go_threads)从大约 20 条增加到大约 55 条.然后在负载消失,这些线程仍然存在,即使经过几个小时.但是我可以看到 go_goroutines 和内存使用量下降,但不是线程.

I have go based reverse proxy server. When I monitor metrics on the app (using prometheus), Ive noticed that when the load on the app goes up, the threads (go_threads) on the app goes from around 20 to about 55. Then after the load goes away, these threads still around, even after many hours. However I can see the go_goroutines and the memory usage go down, but not the threads.

我有几个问题

  • go 中线程池的默认大小是多少?
  • 空闲线程会保留多长时间?

推荐答案

go中线程池的默认大小是多少?

What is the default size of the thread pool in go?

GOMAXPROCS

空闲线程会停留多长时间?

How long do idle threads stick around?

直到进程终止

注意:

代表Go代码在系统调用中可以阻塞的线程数没有限制;这些不计入 GOMAXPROCS 限制.

There is no limit to the number of threads that can be blocked in system calls on behalf of Go code; those do not count against the GOMAXPROCS limit.

这意味着保持低线程数的最佳机会是减少阻塞系统调用.

This means your best chance to keep thread count low is to have few blocking system calls.

这篇关于负载下降后线程仍然存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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