In the world of virtualization computing, the term CPU steal often appears as one of the important metrics that need to be monitored. Especially if you are using a VPS (Virtual Private Server) service, understanding what CPU steal is and how it impacts performance is crucial for maintaining your server’s efficiency.

What is CPU Steal?

CPU steal is the percentage of time allocated by the hypervisor (the software that manages virtualization) to the physical processor for handling tasks from other virtual machines (VMs) within a virtualized environment. In other words, CPU steal occurs when the physical CPU is busy handling requests from other VMs, causing your VM to “wait its turn” to gain access to the CPU. This means that even though the CPU on your VM may not appear to be working hard, there’s a possibility that the CPU is being used by another VM in the same system. The higher the CPU steal value, the greater the impact on the performance of applications or services running on your VPS.

How to Check CPU Steal

To check CPU steal, we can use built-in Linux tools such as mpstat, which is part of the sysstat package. Below are the installation and usage instructions:

Debian/Ubuntu

sudo apt install sysstat

CentOS/RHEL

sudo dnf install sysstat

After the installation is complete, run the following command to check CPU steal:

mpstat 1 5

This command will display CPU statistics every second for 5 iterations. The %steal column shows the CPU steal value.

Example of mpstat Data

Below is an example of the mpstat output when there is no CPU steal:

10:17:20     CPU    %usr   %nice    %sys %iowait    %irq   %soft  %steal  %guest  %gnice   %idle
10:17:21     all    1,51    0,00    1,01    0,00    0,00    0,00    0,00    0,00    0,00   97,49
10:17:22     all    1,50    0,00    1,38    0,00    0,00    0,00    0,00    0,00    0,00   97,12
10:17:23     all    1,52    0,00    0,89    0,13    0,00    0,00    0,00    0,00    0,00   97,47
10:17:24     all    2,39    0,00    1,13    0,00    0,00    0,00    0,00    0,00    0,00   96,48
10:17:25     all    1,51    0,00    1,13    0,00    0,00    0,00    0,00    0,00    0,00   97,36
Average:     all    1,69    0,00    1,11    0,03    0,00    0,00    0,00    0,00    0,00   97,18

Explanation

  • %usr: The percentage of CPU time used for user processes.
  • %sys: The percentage of CPU time used for system processes.
  • %idle: The percentage of CPU time in an idle state (not used).
  • %steal: A value of 0.00 indicates that no CPU time is being “stolen” by other VMs.
    The average %idle of 97.18% shows that the CPU still has plenty of idle time, meaning the server’s performance is optimal.

Here is an example of the mpstat output when there is CPU steal:

10:20:20     CPU    %usr   %nice    %sys %iowait    %irq   %soft  %steal  %guest  %gnice   %idle
10:20:21     all    1,51    0,00    1,01    0,00    0,00    0,00    5,00    0,00    0,00   92,49
10:20:22     all    1,50    0,00    1,38    0,00    0,00    0,00    7,00    0,00    0,00   90,12
10:20:23     all    1,52    0,00    0,89    0,13    0,00    0,00   10,00    0,00    0,00   87,47
10:20:24     all    2,39    0,00    1,13    0,00    0,00    0,00   12,00    0,00    0,00   84,48
10:20:25     all    1,51    0,00    1,13    0,00    0,00    0,00   15,00    0,00    0,00   82,36
Average:     all    1,69    0,00    1,11    0,03    0,00    0,00    9,80    0,00    0,00   89,18

Explanation

  • %steal: A value greater than 0 indicates that the CPU is being used by other VMs. The higher this value, the greater the impact on your VM’s performance.
  • %idle: The percentage of CPU idle time decreases because a portion of the CPU time is allocated to other VMs.
  • An average %steal of 9.80% indicates that nearly 10% of the CPU time is being “stolen” by other VMs, which can lead to latency or reduced application performance.

How to Address CPU Steal

If you encounter a high CPU steal value, here are some steps you can take:

  • Contact Your VPS Service Provider:
    If CPU steal remains consistently high, it could indicate that the hypervisor is overloaded. Contact your service provider to request a solution, such as migrating to a server with a lower load.
  • Upgrade Your Server:
    Consider upgrading your server to a package with a larger allocation of resources.
  • Optimize Resource Usage:
    Ensure your applications are optimized to use resources efficiently. Reduce CPU load by limiting unnecessary processes.
  • Use a Dedicated Server:
    If your application is highly sensitive to latency or requires maximum performance, consider switching to a dedicated server.

Conclusion

CPU steal is an important metric to monitor in virtualized environments such as VPS. A high CPU steal value can indicate that CPU resources are being used by other VMs, which may impact the performance of your applications. By using the mpstat command, you can periodically monitor the CPU steal value.

To address CPU steal, you can contact your service provider, optimize resource usage, or consider upgrading to a better server package. With a good understanding of CPU steal, you can ensure that your VPS continues to run with optimal performance.