Skip to content

Contact sales

By filling out this form and clicking submit, you acknowledge our privacy policy.
  • Labs icon Lab
  • A Cloud Guru
Google Cloud Platform icon
Labs

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.*

Google Cloud Platform icon
Labs

Path Info

Level
Clock icon Advanced
Duration
Clock icon 45m
Published
Clock icon Jun 30, 2021

Contact sales

By filling out this form and clicking submit, you acknowledge our privacy policy.

Table of Contents

  1. Challenge

    Use cgroups to Manage Settings at the PID Level

    1. Launch the cg-review.sh script as a background application.
    2. 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.
    3. 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 = 1000000
        • cpu.cfs_quota_us = 200000
        • Confirm the values are configured.
      • Add the process PID to the cpu/lab/cgroup.procs file for the lab cgroup.
        • Confirm the limit was applied by checking in /proc.
      • Launch top and check for the process, confirming the CPU usage has been limited as expected.
    4. Kill the process.
    5. Exit the root account
  2. Challenge

    Manage Resource Limits Using systemd

    1. 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.
    2. Check the status of the evotl service.
    3. Launch top and review the top memory processes.
      • You should see the tail process consuming approximately 50-55% of the memory.
    4. Use systemctl to set the MemoryLimit property to 1000M.

      Note: This could take a several seconds to complete, be patient.

    5. Check the status of the change.
      • Use systemctl to view the evotl service and confirm a limit file was created.
      • Launch top and confirm the tail process now consumes around 25% of the memory.
  3. Challenge

    Reboot the Lab and Confirm Configuration Persists

    1. Use systemctl to check the status of the evotl service.
      • Confirm the service still has the memory limit in place.
    2. Launch top and monitor the status of the tail process.
      • Confirm the process is currently consuming around 25% of the memory.
  4. Challenge

    Revert the Memory Limit and Disable the Service

    1. Stop the evotl service.
    2. Remove the 50-MemoryLimit.conf file for the evotl service.
    3. Disable the evotl service.

The Cloud Content team comprises subject matter experts hyper focused on services offered by the leading cloud vendors (AWS, GCP, and Azure), as well as cloud-related technologies such as Linux and DevOps. The team is thrilled to share their knowledge to help you build modern tech solutions from the ground up, secure and optimize your environments, and so much more!

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.

Start learning by doing today

View Plans