Kubernetes CPU多线程 [英] Kubernetes CPU multithreading

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

问题描述

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



I想知道在这种情况下100m甚至不是一个完整的内核,如果我的应用程序是多线程应用程序,我的应用程序的线程会并行运行吗?还是所有线程仅在内核(100毫安内核)的一部分中运行? div class = h2_lin>解决方案

我到目前为止找到的最接近的答案是一个


对于单线程程序,cpu用法为0.1表示如果您
可以在随机的某个时间冻结机器,并查看每个内核在做什么
,那么在那个瞬间运行单线程
的机会就有十分之一。机器上的核数确实
不会影响0.1的含义。对于具有多个线程的容器,
的容器使用情况是其线程使用量的总和(根据先前的
定义。)不能保证您运行的是哪个内核,以及
您可能会在
容器生命周期的不同时间在不同的内核上运行
。 cpu限制为0.1表示您的使用量
在相当长的一段时间内不允许超过0.1。 cpu请求
的值为0.1意味着如果线程不经常阻塞
,系统将尝试确保
的cpu使用率至少为0.1。


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


更新:


此外,此答案很好地说明了这一点,尽管它可能在单核(或少于一个核)中运行线程权限),由于操作系统的调度能力,它仍将尝试并行运行指令单元,但不会超过指定的时钟功率(每个问题为100m)。


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.

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:

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.

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.

Update:

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天全站免登陆