2

K8S request limit 资源限制后,为啥 load average 还是很高

 2 years ago
source link: https://www.v2ex.com/t/842973
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

V2EX  ›  Kubernetes

K8S request limit 资源限制后,为啥 load average 还是很高

  dunhanson · 9 小时 46 分钟前 · 305 次点击

我看对应的进程 cpu 已经最大 200%了

request limit 都设置为 2



load average



11 条回复    2022-03-26 01:33:43 +08:00

hwdef

hwdef      9 小时 34 分钟前

kubectl top 看一下,容器里的 top 看资源使用量不一定准确

dunhanson

dunhanson      9 小时 32 分钟前

@hwdef 我在节点上面看的,没有在容器里面

dunhanson

dunhanson      9 小时 30 分钟前

@hwdef kubectl top node 确实占用不高,为啥节点上面用 top 比较高?

hwdef

hwdef      9 小时 30 分钟前

不是你这个 pod 的问题吧,你这 pod 确实也没有超设定值,load average 高的原因有很多,磁盘什么的也会影响,不只是 cpu 和内存,看你这是阿里云的虚拟机,虚拟机底层的主机如果负载高也会造成虚拟机的平均负载高,

总之就是原因很多,不一定是 cpu 的问题

dunhanson

dunhanson      9 小时 28 分钟前

@hwdef 但是确实这个 pod 每次启动后负载都会很高,过几分钟后降下来了

dunhanson

dunhanson      9 小时 26 分钟前

@hwdef 因为这个项目很老,代码比较冗余,我现在代码在精简,有点效果,之前 top 启动的时候负载超过 200 300 ,现在<60 。但还是很高,cpu 总共也就 4 线程

hwdef

hwdef      9 小时 24 分钟前

emmmm 容器优化 jvm 我也不熟,,我是写 go 的,,,感觉 java 上云还是容易水土不服,,

dunhanson

dunhanson      9 小时 17 分钟前

@hwdef 哈哈 难搞

disk

disk      9 小时 12 分钟前 via iPhone

你这个 java 程序是多线程的吗? k8s 只能限制容器的 cpu 使用时间,如果你有多个线程在等 cpu ,负载一样会很高。

dunhanson

dunhanson      9 小时 3 分钟前

@disk

用的基于 tomcat7 的镜像,然后启动脚本是这样子,主要是为了方便看日志

chmod 777 /usr/local/tomcat/bin/catalina.sh
sh /usr/local/tomcat/bin/startup.sh
tee /opt/health.sh <<-'EOF'
while true
do
sleep 1s
if test $( ps -aux | grep java | grep tomcat | wc -l ) -eq 0
then
ps -aux | grep catalina.out | grep -v grep | awk '{print$2}' | xargs kill -9
fi
done
EOF
sh /opt/health.sh &
tail -f /usr/local/tomcat/logs/catalina_${HOSTNAME}.out

dunhanson

dunhanson      9 小时 2 分钟前

CMD ["sh","/usr/local/tomcat/bin/tomcat.sh"]

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK