I would like to isolate processes using lxc-execute. Is it possible to set bandwidth, cpu and memory limit?
I had a look in the man of lxc.conf but I did not find it exhaustive.
I would like to isolate processes using lxc-execute. Is it possible to set bandwidth, cpu and memory limit?
I had a look in the man of lxc.conf but I did not find it exhaustive.
First of all i would like you to understand Cgroups that are a part of the LXC utility. when you have a container, you would obviously want to ensure that the various containers you have running done starve any other container or process within. With this in mind, the nice guy of the LXC project a.k.a Daniel Lezcano integrated cgroups with the container technology he was creating i.e. LXC. Now if you want to assign resource usage, you will need to look into configuring your CGROUP. Cgroups allow you to allocate resources—such as CPU time, system memory, network bandwidth, or combinations of these resources—among user-defined groups of tasks (processes) running on a system. You can monitor the cgroups you configure, deny cgroups access to certain resources, and even reconfigure your cgroups dynamically on a running system. The cgconfig ( control group config) service can be configured to start up at boot time and reestablish your predefined cgroups, thus making them persistent across reboots. Cgroups can have multiple hierarchies because each hierarchy is attached to one or more subsystems (also known as resources controllers or controllers). This will then create multiple trees which are unconnected. There are nine subsystems available.
We can list the subsystems we have in our kernel by the command :
lxc-cgroup get or set value from the control group associated with the container name. Manage the control group associated with a container. example usage:
assign the processors 0 and 3 to the container.
Now, i have in my opinion answered your original question. But let me add a bit of the parameters that might be useful to you for configuring your container for using lxc. there are condensed form of the documentation of resource control by redhat
BLKIO Modifiable Parameters:
RT Modifiable Parameters:
CPUset :
Devices:
Memory:
The memory subsystem generates automatic reports on memory resources used by the tasks in a cgroup, and sets limits on memory use by those tasks Memory modifiable parameters: memory.limit_in_bytes : sets the maximum amount of user memory. can use suffixes like K for kilo and M for mega etc. This only limits the groups lower in the heirarchy. i.e. root cgroup cannot be limited memory.memsw.limit_in_bytes : sets the maximum amount for the sum of memory and swap usage. again this cannot limit the root cgroup.
net_cls:
The net_cls subsystem tags network packets with a class identifier (classid) that allows the Linux traffic controller ( tc) to identify packets originating from a particular cgroup. The traffic controller can be configured to assign different priorities to packets from different cgroups.
net_prio :
The Network Priority ( net_prio) subsystem provides a way to dynamically set the priority of network traffic per each network interface for applications within various cgroups. A network's priority is a number assigned to network traffic and used internally by the system and network devices. Network priority is used to differentiate packets that are sent, queued, or dropped. traffic controller (tc) is responsible to set the networks priority.
This doc is quite helpful: http://doc.opensuse.org/documentation/html/openSUSE/opensuse-tuning/cha.tuning.cgroups.html
The information are in the Linux kernel documentation here: /usr/src/linux/Documentation/cgroups