Kubernetes CPU 多线程

标签 kubernetes cpu

我有一个4核CPU,我创建了一个Kubernetes Pod,CPU资源限制为100m,这意味着它将占用1/10的核心功率。

我想知道在这种情况下,100m甚至不是一个完整的核心,如果我的应用程序是多线程应用程序,我的应用程序的线程会并行运行吗?或者所有线程都只在核心部分(100毫核心)运行?

谁能进一步解释一下背后的机制吗?

最佳答案

到目前为止我找到的最接近的答案是这个 one :

For a single-threaded program, a cpu usage of 0.1 means that if you could freeze the machine at a random moment in time, and look at what each core is doing, there is a 1 in 10 chance that your single thread is running at that instant. The number of cores on the machine does not affect the meaning of 0.1. For a container with multiple threads, the container's usage is the sum of its thread's usage (per previous definition.) There is no guarantee about which core you run on, and you might run on a different core at different points in your container's lifetime. A cpu limit of 0.1 means that your usage is not allowed to exceed 0.1 for a significant period of time. A cpu request of 0.1 means that the system will try to ensure that you are able to have a cpu usage of at least 0.1, if your thread is not blocking often.

我认为上面听起来很合乎逻辑。根据我的问题,100m 核心的 CPU 功率将分布在所有 CPU 核心上,这意味着多线程应该在 Kubernetes 中工作。

更新:

此外,这个answer很好地解释了,虽然它可能在单核中运行一个线程(或者根据问题少于一个核功率),但由于操作系统的调度能力,它仍然会尝试并行运行指令单元,但不会超过指定的时钟功率(根据问题为 100m)。

关于Kubernetes CPU 多线程,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53276398/

相关文章:

docker - Kubernetes 不创建 docker 容器

c++ - i5-2500k 上的 cpuid 指令 : MMX, SSE,SSE2 位未设置

java - 寻找类似于 Hyperic SIGAR 的商业或免费库

c++ - 获取虚拟机中物理处理器的数量

c - 获取 CPU 型号名称、供应商 ID、Windows C 中的物理处理器数量

amazon-web-services - 使用 AWS Java SDK v2 从 AWS EKS 获取身份验证 token

kubernetes - kubectl cp 在运行 nvidia-docker 的节点上失败并显示 "tar: this does not look like a tar archive"

docker - minikube docker-env 是什么意思?

jenkins - 在Openshift中为Jenkins实例配置不同的构建工具

operating-system - 操作系统如何与 CPU 通信?