k8s-gitops icon indicating copy to clipboard operation
k8s-gitops copied to clipboard

high CPU usage for k3s-server

Open carpenike opened this issue 4 years ago • 15 comments

Any chance you've run into this issue?

https://github.com/rancher/k3s/issues/294

I've noticed that my nzbget client doesn't get any more than 5-8MB/s. Node running the pod has a 13/13/13 on load with 4 procs. Turns out that node is also the master and k3s-server process is destroying the local cpu:

image

I think I may try an A/B test with another rke cluster to see if it's any better.

carpenike avatar Dec 20 '19 20:12 carpenike

I just looked and see the k3s-agent process running around 30-45% CPU usage on the nodes I have it installed. Not sure if this is 'normal' or not. I'm subscribed to the issue you linked and curious where the problem may be.

For some comparison, here is a 30-day view of CPU usage for the 7 k3s nodes I run:

image

As an aside, the CPU usage seems a bit higher after moving from raspbian to ubuntu 19.10 (arm64) on the pi4 nodes

billimek avatar Dec 22 '19 16:12 billimek

Unfortunately the other issue was closed. I suppose we would need some test setup using vagrant to prove that k3s consumes more cpu than a similar setup using plain kubeadm or microk8s.

runningman84 avatar Dec 25 '19 10:12 runningman84

Also wondering if the high load may be tied to docker/container networking. I've now proven out that running nzbget on a VM with an NFS mount for storage gets me close to 100MB/s on gigabit internet.

Running the exact same configuration on the same VM with the same host with the same NFS share in a docker container maxes out at 8MB/s. This test node isn't apart of my k3s cluster, so there's no overlay networking going on. Also seeing the high system load experienced within the k3s cluster.

carpenike avatar Dec 26 '19 23:12 carpenike

tested running the nzbget with --net=host and performance is no better.

carpenike avatar Dec 26 '19 23:12 carpenike

and, just for grins, I tried it with Macvlan, same problem. I wonder if there's something with the ubuntu cloud image kernel?

carpenike avatar Dec 26 '19 23:12 carpenike

@carpenike are you running all raspberry pis with ubuntu?

I started looking closer and it seems, for me, after switching from raspbian to ubuntu 19.10 (arm64), they run a lot higher CPU:

raspbian, 48-hour view: image

ubuntu 19.10 (arm64) 48-hour view: image

billimek avatar Dec 28 '19 03:12 billimek

Another point of comparison is a 2-day snapshot of CPU & load compared side-by-side with a node still on raspbian (pi4-b) and a node on ubuntu 19.10 (arm64) (pi4-a): image

billimek avatar Dec 28 '19 03:12 billimek

All amd64 VMs on PVE

carpenike avatar Dec 28 '19 05:12 carpenike

It's too bad they closed the issue on the k3s repo. I'm seeing a pretty steady 30% CPU consumption of the k3s agent on a pi4 node which is cordoned in the cluster, so no workloads are really running there: image

billimek avatar Jan 03 '20 14:01 billimek

@billimek would you be able to provide some vagrant setup which would test k3s, kubeadm and microk8s in order to prove that something is broken in k3s? The developers mentioned that without some test setup which shows big differences they do not see any problem....

runningman84 avatar Jan 03 '20 14:01 runningman84

This is also interesting, going to dig in a bit more but it appears that all the nodes tunnel traffic through the master?

https://reddit.com/r/kubernetes/comments/bj2ebf/_/em55ix4/?context=1

carpenike avatar Jan 18 '20 16:01 carpenike

Do you have many workloads which use an exec based liveness/readiness probes? I came across this issue and wonder if there could be some relationship?

billimek avatar Jan 29 '20 12:01 billimek

I can look into it. Don't we see the same problems with a cordon'ed host though?

carpenike avatar Jan 29 '20 16:01 carpenike

The same on Ubuntu 18, even after clean install - about 12% CPU usage in top goes to k3s-server process.

iirekm avatar Feb 03 '20 11:02 iirekm

Somebody offered help https://github.com/rancher/k3s/issues/1635

runningman84 avatar Apr 13 '20 15:04 runningman84