使用cgroup将每位客户的cpu使用率限制为25% [英] Restrict cpu usage to 25 % per customer base using cgroups

查看:119
本文介绍了使用cgroup将每位客户的cpu使用率限制为25%的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I want to restrict cpu usage of users to only 25% . For this i am using cgroups.

这是我要遵循的指南: http://kaivanov.blogspot.in/2012/07/setting-up-linux-cgroups-control-groups.html

Here is the guide that I am following : http://kaivanov.blogspot.in/2012/07/setting-up-linux-cgroups-control-groups.html

本指南适用于一核cpu机器,但是当我与4核cpu机器一起使用时,此配置无效.

This guide work with one core cpu machine, but when i am using with the 4 core cpu machine this configuraion doe not work.

这是我的配置:

 # 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的cpu值是test1的两倍.份额是成比例的,它们没有考虑机器大小.如果要严格限制cgroup的使用,则需要使用cfs_period_us和cfs_quota_us.要在计算机上使用1个内核的CPU,请将cfs_quota_us设置为与cfs_period_us(100000)相同.

The configuration you shared just means that test2 will get twice the cpu as test1. Shares are proportional, they don't take machine size into account. If you want to hard-cap the usage for a cgroup, you need to use cfs_period_us and cfs_quota_us. To use 1 core worth of cpu from a machine, set cfs_quota_us to be same as cfs_period_us (100000).

这篇关于使用cgroup将每位客户的cpu使用率限制为25%的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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