2

From yesterday I'm struggling with problem with LXC containers and limiting CPU resources per container. In my case command like lxc-cgroup -n srv50 cpu.shares 100 doesn't bring any results - containers still use CPU equally.

I'm using Centos 7 & LXC 1.0.8. All machines where I was checking that had the same effect: setting cpu.shares doesn't do anything.

Here's systemd-cgtop screen, from my 2 cores VM:

Path                                                                             Tasks   %CPU   Memory  Input/s Output/s

/                                                                                  178  199.7   360.8M        -        -
/lxc                                                                                 -  198.0    16.8M        -        -
/lxc/srv51                                                                           7   99.8     8.4M        -        -
/lxc/srv50                                                                           7   98.2     8.4M        -        -
/system.slice/NetworkManager.service                                                 2      -        -        -        -
/system.slice/auditd.service                                                         1      -        -        -        -

Container srv50 has cpu.shares set to 100, whereas srv51 set to 50. Both containers run command dd if=/dev/urandom | bzip2 -9 >> /dev/null. I was expecting one container takes 66% and other 133% CPU (or something like that), but both use 100%.

One hint. When I was trying find which one container uses the most CPU I noticed in htop tool that all containers have the same cgroup: :name=systemd:/user.slice/user-0.slice/session-1.scope? - not sure whether this is correct or not - just noticed that.

Limiting memory works, CPU nope.

I've just done testing cgroups and I can't set cpu.share for any process (by moving it to some group), so it's consistent. Smells like some missing kernel switch.

2: There's a bug in my example. To see difference in load on 2 cores machine, we must have at least 2 processes running 100% per container. Anyway, this is not an issue.

0

Yes, the issue in this case was with testing this feature. It works as expected. The only one issue I had on other cloud VM with 2 cores. As I don't need it, I won't be thinking about it any more. :) Cheers!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.