<p>Scenario: On a 16-core node, a Go service/container is run in a pod with another container, where the other is allocated 4 cores, and the go container is set to use <code>GOMAXPROCS</code>.</p>

<p>In requests that use goroutines, will the Go program utilize all CPU's available to it. I think this is dependant on <code>GOMAXPROCS</code>, but am unsure if it only sees the 1 core used at pod startup, are all on the machine.</p>

<p>Ideally, I'd like for cpu-intensive requests to use all available CPUs, but am having a hard time measuring what's actually happening at runtime (GKE).</p>

<p><code>kube top</code> shows what is expected in idle:</p>

<pre><code>POD        NAME            CPU(cores)   MEMORY(bytes)
pod-go-py  go-service      1m           862Mi
pod-go-py  py-service      4m           489Mi
</code></pre>

<p><code>fmt.Println(runtime.NumCPU())</code> shows 16 core available. So I can trust that the Go program will utilize them all in the requests? I also imagine as I scale the pods on the node that Ill have to be mindful of throttling. </p>

Michael Ramos
<p>The container will see all cores on the machine. What Kubernetes limits do is setup cgroup that tell the kernel how much CPU the container can consume. That means that while Go will see all the cores, when he tries to go above the limit the kernel will throttle it. That's actually a bad thing. You want Go to be aware of cgroups and scale GOMAXPROCS appropriately. For that you can use <a href="https://github.com/uber-go/automaxprocs" rel="noreferrer">this</a></p>

<p>It looks like what you want is oversubscription. Set requests very low and limit to 4 cores on the first container. Set requests very low but limit to 16 cores (or don't set the limit at all) on the second. That way the second container will be able to utilize all the CPU.</p>
