如何为容器设置合适的cpu千分率? [英] How to set the right cpu millicores for a container?

查看:96
本文介绍了如何为容器设置合适的cpu千分率?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在不过度分配或分配不足的情况下,对CPU内核进行最佳配置.如何测量给定容器所需的CPU毫核心?它还带来了一个问题,即基于CPU消耗,代理会将多少流量发送给任何给定的pod,以便我们可以最佳地使用计算.

I want to optimally configure the CPU cores without over or under allocation. How can I measure the required CPU millicore for a given container? It also brings the question of how much traffic a proxy will send it to any given pod based on CPU consumption so we can optimally use the compute.

当前,我发送请求并进行监视,

Currently I send requests and monitor with,

kubectl top pod

是否有任何工具可以随时间测量,请求,CPU和内存,并为Pod提供最佳的CPU建议.

Is there any tool that can measure, Requests, CPU and Memory over the time and suggest the optimal CPU recommendation for the pods.

推荐答案

随着时间的推移和每个Pod的监视,是的,在 https://grafana.com/dashboards/315

Monitoring over time and per Pod yes, there's suggestions at https://kubernetes.io/docs/tasks/debug-application-cluster/resource-usage-monitoring/ One of the more popular is the Prometheus-Grafana combination - https://grafana.com/dashboards/315

关于请求和限制的自动建议,我认为没有任何内容.请记住,Kubernetes已经尝试平衡给每个Pod所需的东西,而不会花费太多.您设置的限制和要求是为了帮助它更安全地执行此操作.由于资源不足的Pod仍然可以工作,但响应速度较慢,因此自动推理有一定的局限性-由您决定您可以容忍的缓慢程度.您还可以决定高峰负载下可接受的资源消耗级别,而不是可能表明您的应用存在错误甚至是攻击的过度消耗.还有一个局限性,因为度量单位本身就是一种估算资源能力的尝试,而资源能力实际上会随硬件类型而变化(内存和CPU的运行方式和数量可能会有所不同),因此可能会跨集群甚至是节点上的节点而变化.如果硬件不完全相同,则集群.

As for automatic suggestion of the request and limits, I don't think there is anything. Keep in mind Kubernetes already tries to balance giving each Pod what it needs without it taking too much. The limits and requests that you set are to help it do this more safely. There are limitations on automatically inference as an under-resourced Pod can still work but respond a bit slower - it is up to you to decide what level of slowness you would tolerate. It is also up to you to decide what level of resource consumption could be acceptable in peak load, as opposed to excessive consumption that might indicate a bug in your app or even an attack. There's a further limitation as the metric units are themselves an attempt to approximate resource power that can actually vary with types of hardware (memory and CPUs can differ in mode of operation as well as quantity) and so can vary across clusters or even nodes on a cluster if the hardware isn't all equal.

在我看来,您对top做的事情是入门的好方法.无论如何,您都希望监视群集的资源使用情况,因此跟踪并随时调整限制是一个好主意.如果您可以在kubernetes之外运行相同的应用程序并四处浏览以查看其他使用相同语言的应用程序可以做什么,那么这将有助于表明您是否可以采取任何措施来提高利用率(例如,众所周知,容器中JVM上的内存消耗是必需的)进行一些调整以获得正确的位置).

What you are doing with top seems to me a good way to get started. You'll want to monitor resource usage for the cluster anyway so keeping track of this and adjusting limits as you go is a good idea. If you can run the same app outside of kubernetes and read around to see what other apps using the same language do then that can help to indicate if there's anything you can do to improve utilisation (memory consumption on the JVM in containers for example famously requires some tweaking to get right).

这篇关于如何为容器设置合适的cpu千分率?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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