- Lab
- A Cloud Guru
Managing System Resources Using Control Groups
In this hands-on lab, you will focus on managing system resource limits using `control groups` (`cgroups`). Using `top` or a similar tool, you will review CPU activity and identify the `PID` of a high CPU process, then create a control group and set a limit using the `PID` value and confirm the limits were properly applied. The final task will be to start a service, monitor the CPU utilization, and create a permanent resource limit using a `systemd` control file for the service. *This course is not approved or sponsored by Red Hat.*
Path Info
Table of Contents
-
Challenge
Use cgroups to Manage Settings at the PID Level
- Launch the
cg-review.sh
script as a background application. - Launch your preferred utility to monitor processes and monitor CPU and memory utilization, such as
top
.- Identify any processes that are consuming excess CPU and note the
PID
value.
- Identify any processes that are consuming excess CPU and note the
- Configure the limit values:
- Create a directory called
lab
in/sys/fs/cgroup/cpu/
.- Confirm the directory is populated.
- As the
root
user, set the limits as follows:cpu.cfs_period_us
= 1000000cpu.cfs_quota_us
= 200000- Confirm the values are configured.
- Add the process PID to the
cpu/lab/cgroup.procs
file for thelab
cgroup.- Confirm the limit was applied by checking in
/proc
.
- Confirm the limit was applied by checking in
- Launch
top
and check for the process, confirming the CPU usage has been limited as expected.
- Create a directory called
- Kill the process.
- Exit the root account
- Launch the
-
Challenge
Manage Resource Limits Using systemd
- Enable and start the
evotl
service.Note: This service will cause the
systemd-journald
service to consume around 50% of the CPU at times. This is ok for the purposes of the lab.- This service spawns a
tail
process that consumes around 2G of memory.
- This service spawns a
- Check the status of the
evotl
service. - Launch
top
and review the top memory processes.- You should see the
tail
process consuming approximately 50-55% of the memory.
- You should see the
- Use
systemctl
to set theMemoryLimit
property to 1000M.Note: This could take a several seconds to complete, be patient.
- Check the status of the change.
- Use
systemctl
to view theevotl
service and confirm a limit file was created. - Launch
top
and confirm thetail
process now consumes around 25% of the memory.
- Use
- Enable and start the
-
Challenge
Reboot the Lab and Confirm Configuration Persists
- Use
systemctl
to check the status of theevotl
service.- Confirm the service still has the memory limit in place.
- Launch
top
and monitor the status of the tail process.- Confirm the process is currently consuming around 25% of the memory.
- Use
-
Challenge
Revert the Memory Limit and Disable the Service
- Stop the
evotl
service. - Remove the
50-MemoryLimit.conf
file for theevotl
service. - Disable the
evotl
service.
- Stop the
What's a lab?
Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.
Provided environment for hands-on practice
We will provide the credentials and environment necessary for you to practice right within your browser.
Guided walkthrough
Follow along with the author’s guided walkthrough and build something new in your provided environment!
Did you know?
On average, you retain 75% more of your learning if you get time for practice.