Serhiy
Serhiy

Reputation: 369

Why CPU Utilization on VM Instance has intervals? (Google Cloud Platform)

I'm new to the google cloud platform and currently trying to understand the CPU utilization chart. (Attaching below). This is the chart for medium machine type with the 2 reserved vCPUs.

enter image description here enter image description here

What I can't understand is, why CPU utilization has this pattern (line goes up and down, from 5% to 26% again and again), when my machine usage is more or less linear. I know, that small machines are allowing CPU bursting, but it doesn't seem to be an explanation, since my usage never topped the CPU cap.

Details on VM:

Will be grateful for any hint!

Upvotes: 0

Views: 779

Answers (1)

Wojtek_B
Wojtek_B

Reputation: 4443

Metric you mentioned indicates that some process on your VM uses the CPU in a specific time intervals.

Without more information it's a guessing game to figure out why your chart spikes from 5 to 25% and back.

To nail down the process that's causing it you may try using ps or more "human friendly" htop commands and see what's going on your system.

for example:

$ ps -eo pid,ppid,cmd,%mem,%cpu --sort=-%mem | head
  PID  PPID CMD                         %MEM %CPU
  397     1 /usr/bin/google_osconfig_ag  0.7  0.0
  437     1 /usr/bin/google_guest_agent  0.5  0.0
  408     1 /usr/bin/python3 /usr/share  0.4  0.0
    1     0 /sbin/init                   0.2  0.0
  234     1 /lib/systemd/systemd-journa  0.2  0.0
17419     1 /lib/systemd/systemd --user  0.2  0.0
17416   543 sshd: wb [priv]         0.2  0.0
  575     1 /lib/systemd/systemd-logind  0.1  0.0
  543     1 /usr/sbin/sshd -D            0.1  0.0

Here's some tips on how to use ps and another usefull Q & A regarding it.

Have a look at this answer - it may give you some insight.

Also - this is what the official GCP docs say about the CPU usage metric collected from the agent running on the VM:

Percentage of the total CPU capacity spent in different states. This value is reported from inside the VM and can differ from compute.googleapis.com/instance/cpu/utilization, which is reported by the hypervisor for the VM. Sampled every 60 seconds.

cpu_number: CPU number, for example, "0", "1", or "2". This label is only set with certain Monitoring configurations. Linux only.

cpu_state: CPU state, one of [idle, interrupt, nice, softirq, steal, system, user, wait] on Linux or [idle, used] on Windows.

Upvotes: 1

Related Questions