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

add go-max-procs annotation #333

Merged
merged 2 commits into from
Apr 28, 2022

Conversation

packageman
Copy link
Contributor

When Golang program started in a container, the P (from Golang GMP model) will be set to the number of CPU cores of host instead of container's CPU limit (cgroups).

Assuming vault-agent sidecar is deployed on a 16core64g machine, the P of vault-agent will be set to the number of CPU cores by default, which is 16, and the available CPU of the vault-agent is 500m (helm chart default setting), which will cause the CPU to be used too high constantly. Solved by explicitly setting GOMAXPROCS to 1.

Therefore, add annotation vault.hashicorp.com/go-max-procs to support configuring P's number accordingly.

  • P = 16

perf-vault-agent

image

  • P = 1

image

@hashicorp-cla
Copy link

hashicorp-cla commented Apr 8, 2022

CLA assistant check
All committers have signed the CLA.

@tvoran
Copy link
Member

tvoran commented Apr 12, 2022

Thanks for the analysis here! This looks pretty straightforward, but would you mind testing for that variable in agent-inject/agent/container_env_test.go?

@packageman
Copy link
Contributor Author

@tvoran tests added.

Copy link

@swenson swenson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. I pulled this down and tested it, and it seems to work as expected. Thanks!

@swenson swenson merged commit 0e73c98 into hashicorp:main Apr 28, 2022
@packageman packageman deleted the refine-agent-gomaxprocs branch May 5, 2022 02:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants