Automatically set GOMAXPROCS according to linux container cpu quota #2033
Labels
feat
New feature or request.
good first issue
A good issue to tackle when being a novice to the project.
help wanted
We are looking for help on this one.
Milestone
Is your feature request related to a problem? Please describe.
As you know, in Go 1.5, GOMAXPROCS is automatically set to number of cpus. This does not take into account the CPU quotas allocated to the container through the cgroups, and this leads to serious throttling of the process.
More context:
https://medium.com/omio-engineering/cpu-limits-and-aggressive-throttling-in-kubernetes-c5b20bd8a718
Describe the solution you'd like
Possible solution:
Describe alternatives you've considered
There are several ways to fix this:
GOMAXPROCS
cfs-aware onGOOS=linux
golang/go#33803The first solution is not optimal, since every time you change the limits and requests, you will need to independently calculate and set the value for GOMAXPROCS.
The second solution is rather naive - we need some kind of temporary solution now
The third solution may be a compromise, but in this case this feature should be disabled by default (since there may be cgroups v2, which is currently not supported by automaxprocs library)
Additional context
This library can help
https://github.com/uber-go/automaxprocs
The text was updated successfully, but these errors were encountered: