GOMAXPROCS for Go service in Kubernetes

4/9/2020

I'm trying to stress test our Go service in kubernetes. The service is just an http server that accepts requests, send requests to another service, perform some string manipulations and return back response to the original request.

We started with

cpu.requests = 1
cpu.limit = 2
Note: host VM has 6 CPUs

With the following test scenario:

Repeat for 20 times:
1. Send 40 parallel requests
2. Sleep for 200ms

What we observed is Gomaxprocs by default is set to 6 (following host specs) and we get network i/o timeout after some iterations of test. In addition, cpu consumption falls to 0 after some time (any idea what might happen here? Go runtime scheduler get stuck?)

Issue is resolved by setting Gomaxprocs explicitly to 1.

Some basic Googling led me to article like https://github.com/uber-go/automaxprocs/issues/12 But not many other articles/documentations that warn us about this GOMAXPROCS behavior on kubernetes.

Help appreciated:

  1. Any other articles that elaborate how misconfigured GOMAXPROCS affect Go service in kubernetes?
  2. What to do if cpu.requests is set to 500mCPU? is GOMAXPROCS=1 still adequate? or it simply means cpu.requests must be at least 1?
-- Dian Bakti
concurrency
go
kubernetes

0 Answers