Resource Allocation For Linux With Cgroups Presentation
Resource Allocation For Linux With Cgroups Presentation
Resource Allocation For Linux With Cgroups Presentation
Steven Ellis
CGroups
What
Why
How
Originally developed by Rohit Seth in 2006 under the name Process Containers Kernel merge in 2.6.24, now included in most major distributions
Resource Management with CGroups
CGroup Controllers
Allows for setting limits on RAM and swap usage and querying cumulative usage of all processes in the group Binding of processes within a group to a set of CPUs and controlling migration between CPus Information about CPU usage for a group of processes Controlling the priorization of processes in the group. Think of it as a more advanced nice level Access control lists on character and block devices
Resource Management with CGroups
CGroup Controllers
Sets limits on input/output access to and from block devices such as physical drives (disk, solid state, USB, etc.). Suspend or resumes tasks Tags network packets so the Linux traffic controller can identify packets with a particular CGroup
freezer:
Why
SLA Management
Meet application SLAs by reducing resource contention and increasing predictability in performance.
Prevent single or group of virtual machines monopolising resources., or impacting other environments.
When
2009/2010
Mobile Messaging Company Database backups were impacting production services. Very I/O intensive queries
Global Coverage
2006
Multiple Websphere JVM's on shared hardware. Memory leaks and CPU peaks were impacting other business services.
2003-2004
Can not SSH into host. Physical TTY would timeout before login. Power button wouldn't work.
10
11
1998-1999
IMAP email Samba / AFS / NFS GNU Cross-Compilers GDB over serial for Embedded Hardware Remote X via VNC to Mac Workstations
12
20% net
Virt Guest C
25% CPU 25% Mem
60%
20% Storage
20% I/O
13
How
14
Using CGroups
15
cgexec
cgclassify
cgcreate / cgdelete
cgset
16
Subsystems - memory
Examples:
17
Subsystems - cpu
Example:
18
Subsystems - cpuacct
Example:
Members of 'developers' used 107 cpu cycles. Out of that, only 2x106 cpu cycles were exhausted by mySQL.
19
Apache Example
Edit /etc/cgconfig.conf
CGROUP_DAEMON="memory:/http"
20
Allows to control libvirtd and any other process in the cgroup virt
Examples are memory ceiling / capping Restrict which CPUs libvirt can utilise
group virt { memory { memory.limit_in_bytes = 3.5G; } cpuset { cpuset.cpus = 1-3; } }
CGROUP_DAEMON="memory:/virt
21
Subsystems - blkio
proportional weight-based disk access Weight from 1-1000 Upper limit throttling
22
Blkio Demo
# restart cgroups service cgconfig restart # Setup the throttle as zero and then play with it. cd /cgroup/blkio/ echo 253:0 $((0*1024*1024)) > blkio.throttle.write_bps_device #Monitor I/O with iostat dm-0 3 # Then start DD on the volume while true; do dd if=/dev/zero of=/tmp/test.out; done # Adjust blkio throttle and check iostart output echo 253:0 $((20*1024*1024)) > blkio.throttle.write_bps_device echo 253:0 $((10*1024*1024)) > blkio.throttle.write_bps_device echo 253:0 $((1*1024*1024)) > blkio.throttle.write_bps_device
23
References
http://docs.redhat.com/docs/enUS/Red_Hat_Enterprise_Linux/6/html/Resource_Management_Guide
Fedora Overview
http://fedoraproject.org/wiki/Features/ControlGroups
http://broadcast.oreilly.com/2009/06/manage-your-performance-with-cgroups-andprojects.html
http://www.serverwatch.com/tutorials/article.php/3920051/Introduction-to-LinuxCgroups.htm
http://hydra.geht.net/tino/english/faq/debian/squeeze/cgroups/
24
Images
Clipart
http://www.cksinfo.com/clipart/electronics/phones/mobilephones/camera-phone.png
Corporate logos (c) current owners. Pointy Headed Boss c/o Scott Adams
Used under fair use, please contact me if you want this removed.
25