- Lab
-
Libraries: If you want this lab, consider one of these libraries.
- Cloud
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.*
Lab Info
Table of Contents
-
Challenge
Use cgroups to Manage Settings at the PID Level
- Launch the
cg-review.shscript 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
PIDvalue.
- Identify any processes that are consuming excess CPU and note the
- Configure the limit values:
- Create a directory called
labin/sys/fs/cgroup/cpu/.- Confirm the directory is populated.
- As the
rootuser, 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.procsfile for thelabcgroup.- Confirm the limit was applied by checking in
/proc.
- Confirm the limit was applied by checking in
- Launch
topand 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
evotlservice.Note: This service will cause the
systemd-journaldservice to consume around 50% of the CPU at times. This is ok for the purposes of the lab.- This service spawns a
tailprocess that consumes around 2G of memory.
- This service spawns a
- Check the status of the
evotlservice. - Launch
topand review the top memory processes.- You should see the
tailprocess consuming approximately 50-55% of the memory.
- You should see the
- Use
systemctlto set theMemoryLimitproperty to 1000M.Note: This could take a several seconds to complete, be patient.
- Check the status of the change.
- Use
systemctlto view theevotlservice and confirm a limit file was created. - Launch
topand confirm thetailprocess now consumes around 25% of the memory.
- Use
- Enable and start the
-
Challenge
Reboot the Lab and Confirm Configuration Persists
- Use
systemctlto check the status of theevotlservice.- Confirm the service still has the memory limit in place.
- Launch
topand 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
evotlservice. - Remove the
50-MemoryLimit.conffile for theevotlservice. - Disable the
evotlservice.
- Stop the
About the author
Real skill practice before real-world application
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.
Learn by doing
Engage hands-on with the tools and technologies you’re learning. You pick the skill, we provide the credentials and environment.
Follow your guide
All labs have detailed instructions and objectives, guiding you through the learning process and ensuring you understand every step.
Turn time into mastery
On average, you retain 75% more of your learning if you take time to practice. Hands-on labs set you up for success to make those skills stick.