-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Worker Processes (auto) doesn't honor cgroup allocations #2948
Comments
@Stono I found this nginxinc/docker-nginx#31 (comment) I am working on a more idiomatic fix |
Hey Interestingly:
That's returning the node value. I'm setting the limits like this:
Strangely the memory cgroup is fine:
I think maybe you're looking for this:
|
@Stono please post the output of |
pretty useless really:
/sys/fs/cgroup/cpu/cpu.cfs_quota_us is the one which returns the cpu shares from limits *100 |
round_up( This should be used only if |
That wouldn't be right though, as I've only given it 0.5?
…On Thu, 23 Aug 2018, 10:16 pm Manuel Alejandro de Brito Fontes, < ***@***.***> wrote:
round_up(/sys/fs/cgroup/cpu/cpu.cfs_period_us /
/sys/fs/cgroup/cpu/cpu.cfs_quota_us)
100000 / 50000 = 2 (cpus)
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#2948 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABavieF9N1W_uZEWXkdS5kd2ExpA8wpHks5uTxuSgaJpZM4V_TKu>
.
|
@Stono actually it's right https://www.kernel.org/doc/Documentation/scheduler/sched-bwc.txt
|
Hmm interesting. I'm still not sure we have got this right 😂 but I'm certainly no expert. I'll see if there is anyone at work who can wrap their head around this |
@aledbf so I've been going off https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/#meaning-of-cpu:
So taking 1000m(illicores) to = 1 core. My limits above are 500m, or 0.5 cores, but by your calculations it's 2 cores? |
@Stono first, cgroup cpu limits != cpu cores because cgroups limits are time-based. In this case (NGINX) we just need a more suited value than real number of cores. |
Fair enough, like I say, I'm definitely no expert here :) I'm purely going off the Kubernetes docs which tell me that specify "1" for my cpu limit translates into "1" core. I'll continue to hard code worker threads in the config map to match my limit setting in Kubernetes. |
Just in case, I cannot find any helper in the k8s codebase that converts limits to cores |
Guys our problem with "auto" being the amount of cpus in a system is this: Imagine a deployment with a 2 CPU and 1 GB of RAM limit deployed to a) a kubernetes node with 64 CPU's and b) a node with 16 CPU's. On the big machine nginx spawns 64 processes which exceeds in total the configured limit of 1GB RAM. On the node with 16 CPU's it works... I would love to have "auto" being the configured cpu limit or the amount of cpus if limit > $amount-of-cpus-on-this-node. Does this makes sense to you guys? |
Not sure what you mean @mmack, @aledbf PR will attempt to discern a good value for the number of worker threads based on your cgroup limits, if those aren't set, it'll default to the nodes number of cpus. With the changes he's put in, a 2cpu and 1gb instance of nginx on a 64vcpu host, won't spawn 64 threads, if you set an appropriate limit (once this is merged). I still have my reservations about the way it's being calculated however, so in my case I'm opting to set cpu limits, and then using Either way, once this PR is merged it'll be a lot better. |
For future readers trying to follow the logic (as I just did). The code change looks correct (to me) and does
Where as a comment had a typo and said:
Instead it probably should have been
|
I think the worker processes should be based on the resource requests, not the cgroup limits. @aledbf Thoughts? Should I fill a new issue for that? |
Agree. That's why you should not set any limits when you start using the ingress controller, at least for a day, where you can see exactly the resource utilization you have with your apps.
What do you mean? |
Right now this runs as many workers as the the limit of cpus it can use. If all workers are utilized 100%, every bit more cpu it would use (due to the go process etc) would cause some throttling. So instead it would be nice it if uses the resource requests to calculate the number of workers. That's something you set to a value you ideally want to utilize. Does that make sense? |
Sorry for the late pickup, but I agree with @discordianfish on (1) recommending to set requests for ingress (I talked about it here) and (2) using |
Apparently using auto doesn't work well with docker: nginxinc/docker-nginx#31
Hey,
I've noticed that when using the default value of https://github.com/kubernetes/ingress-nginx/blob/master/docs/user-guide/nginx-configuration/configmap.md#worker-processes, it is getting defaulted to the underlying node vCPU count, rather than that of the container.
It might be better to do a calculation based on the cgroup shares, and if that's not set, fall back to the node cpu count.
The text was updated successfully, but these errors were encountered: