Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatically set GOMAXPROCS according to linux container cpu quota #2033

Closed
drwatsno opened this issue Aug 31, 2020 · 1 comment
Closed
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

Comments

@drwatsno
Copy link
Contributor

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:

  1. ADD CGROUPS_V1_AUTO_MAX_PROCS_ENABLED option. Defaults to false
  2. If true, set GOMAXPROCS automatically according to cpu quota

Describe alternatives you've considered

There are several ways to fix this:

  1. Install GOMAXPROCS manually via env variables.
  2. Wait until the problem is solved in Go itself, and do nothing runtime: make GOMAXPROCS cfs-aware on GOOS=linux golang/go#33803
  3. Set GOMAXPROCS automatically using cgroups hierarchy

The 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

@aeneasr aeneasr added 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. labels Aug 31, 2020
@aeneasr aeneasr added this to the v1.8.0 milestone Aug 31, 2020
@aeneasr
Copy link
Member

aeneasr commented Aug 31, 2020

Sounds like a good idea! Contributions welcomed :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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.
Projects
None yet
Development

No branches or pull requests

2 participants