Ceiling enforcement can be used for cases when a hard limit on the amount of CPU that a cgroup can utilize is required
当一个资源组里,同时设置了 cfs_quote_us 和 shares,会怎样呢?
下面通过场景来回答这个问题。
场景 1
假设系统有3 个 CPU 核,有2个资源组 A、B,配置如下:
A.shares : B.shares = 2:1
A 用 2 个 CPU、B 用 1 个 CPU,把系统压满了。这是,增加如下设置:
A.cfs_quote_us = 100ms
A.cfs_period_us = 100ms
这时,A 只能用 1 个 CPU 了。而 B 呢?因为还有空闲 CPU,B 会用满 2 个 CPU。
场景 2
假设系统有 4 个 CPU 核,有 3 个资源组 A、B、C,配置如下:
A.shares : B.shares : C.shares = 2:1:1
A 用 2 个 CPU、B 用 1 个 CPU、C 用 1 个 CPU,把系统压满了。这是,增加如下设置:
A.cfs_quote_us = 100ms
A.cfs_period_us = 100ms
这时,A 只能用 1 个 CPU 了。而 B、C 呢?B 会用 1.5 个 CPU、C 会用 1.5 个 CPU。
所以说,当资源组的资源被 quota 限制住后,它就不再参与 share 竞争了,剩下的资源由其它 share 之间瓜分。

当同时设置cfs_quota_us和shares时,资源组的CPU使用将受到限制。例如,A资源组在满载情况下,设置cfs_quota_us后,只能使用1个CPU,而剩余资源由其他组按shares比例分配。B和C资源组在A受限后,会根据shares瓜分CPU。总结来说,quota限制后的资源不再参与shares竞争,由未达限额的组按shares比例共享。
最低0.47元/天 解锁文章
1985

被折叠的 条评论
为什么被折叠?



