Why is my Linode CPU Usage graph disagreeing with top?
The CPU usage of my 8GB Linode instance shows as hovering around 15-20% on the Linode panel.
<img alt="CPU graph" src="https://i.imgur.com/i72eFRG.png">
However, when I run top (or htop, etc.) I see that it reports, on average, less than 2% usage most of the time.
<img alt="top output" src="https://i.imgur.com/AAdP8Lg.png">
What's up with this discrepancy? Why does the panel show much higher CPU usage? Will this affect any kind of CPU limiting done on my system?
3 Replies
The Linode graphs are out of numvCPUs*100% (so in your case, 400%), whereas top is out of 100% (which explains about half the difference in itself). The Linode graphs look at the entire QEMU process that runs your Linode, rather than just the threads that correspond to the KVM vCPUs. Other QEMU threads handle various I/O operations and other tasks that consume CPU on the host (which shows up in Linode's graphs, but not in top/htop/etc within the Linode). Linode only controls CPU usage by limiting how many vCPUs are presented to your Linode, and not with other means like cgroups.
It can be caused by particular system calls which to your vm's eyes are cheap to run, but to the host are expensive because they aren't hardware accelerated.
Minecraft did cause 99% load on the host and 20% load on the vm due to a system call that was called in a tight loop.