【问题标题】:Restrict cpu usage to 25 % per customer base using cgroups使用 cgroup 将每个客户群的 cpu 使用率限制为 25%
【发布时间】:2015-02-25 12:31:23
【问题描述】:

我想将用户的 cpu 使用率限制为仅 25% 。 为此,我正在使用 cgroups。

这是我正在关注的指南: http://kaivanov.blogspot.in/2012/07/setting-up-linux-cgroups-control-groups.html

本指南适用于一台核心 cpu 机器,但当我使用 4 核心 cpu 机器时,此配置不起作用。

这是我的配置:

 # Configuration file generated by cgsnapshot
mount { 
    cpu = /cgroup/cpu;  
}

group test1 {
    cpu {
        cpu.rt_period_us="1000000";
        cpu.rt_runtime_us="0";
        cpu.cfs_period_us="100000";
        cpu.cfs_quota_us="-1";
        cpu.shares="250";
    }
}

group test2 {
    cpu {
        cpu.rt_period_us="1000000";
        cpu.rt_runtime_us="0";
        cpu.cfs_period_us="100000";
        cpu.cfs_quota_us="-1";
        cpu.shares="500";
    }
}

我错过了什么?

提前致谢。

【问题讨论】:

  • 您分享的配置只是意味着 test2 将获得两倍于 test1 的 cpu。份额是成比例的,它们不考虑机器大小。如果要对 cgroup 的使用量进行硬限制,则需要使用 cfs_period_us 和 cfs_quota_us。要从一台机器使用 1 个核心的 cpu,请将 cfs_quota_us 设置为与 cfs_period_us (100000) 相同。
  • 非常感谢。有没有办法限制使用 cgroups 的进程数?
  • 暂时没有。已经提出了补丁,但没有一个补丁进入上游 linux 内核。

标签: linux shell cpu-usage user-accounts cgroups


【解决方案1】:

您共享的配置仅意味着 test2 将获得两倍于 test1 的 cpu。份额是成比例的,它们不考虑机器大小。如果要对 cgroup 的使用量进行硬限制,则需要使用 cfs_period_us 和 cfs_quota_us。要从一台机器使用 1 个核心的 cpu,请将 cfs_quota_us 设置为与 cfs_period_us (100000) 相同。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-01-19
    • 2018-08-21
    • 2020-06-23
    • 1970-01-01
    • 2011-02-26
    • 2017-01-25
    • 1970-01-01
    相关资源
    最近更新 更多