Kubernetes CPU 多线程 [英] Kubernetes CPU multithreading

查看:25
本文介绍了Kubernetes CPU 多线程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have a 4 cores CPU, I create a Kubernetes Pod with CPU resource limit 100m, which mean it will occupy 1/10 of a core power.

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

I wondering in this case, 100m is not even a full core, if my app is a multithread app, will my app's threads run in parallel? Or all the threads will run in the part of core (100 milli core) only?

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

Can anyone further explain the mechanism behind?

推荐答案

目前我找到的最接近的答案是这个 一个:

The closest answer I found so far is this one:

对于单线程程序,0.1的cpu使用意味着如果你可以在随机时刻冻结机器,看看什么每个核心都在做,你的单线程有十分之一的机会在那一刻正在运行.机器上的核心数确实不影响0.1的意义.对于多线程的容器,容器的使用量是其线程使用量的总和(根据之前的定义.)无法保证您在哪个内核上运行,并且您可能会在不同的核心上运行容器的生命周期.cpu 限制为 0.1 意味着您的使用不是允许在很长一段时间内超过 0.1.cpu请求0.1 表示系统将尝试确保您能够如果您的线程没有阻塞,则 CPU 使用率至少为 0.1经常.

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 中工作.

I think above sound quite logical. Based on my question, 100m core of CPUs power will spread across all the CPU cores, which mean multithreading should work in Kubernetes.

更新:

此外,这个 answer 很好地解释了这一点,尽管它可能在单核(或更少比一个核功率(如题),由于操作系统的调度能力,它仍会尝试并行运行指令单元,但不会超过规定的时钟功率(如题为 100m).

In addition, this answer explain quite well that, although it might be running a thread in single core (or less than one core power as per question), due to operating system's scheduling capability, it will still try to run the instruction unit in parallel, but not exceed the clocking power (100m as per question) as specified.

这篇关于Kubernetes CPU 多线程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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