-
Notifications
You must be signed in to change notification settings - Fork 39.8k
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
1000+ services in the same namespace will degrade pod start time & eventually prevent pods from starting #92615
Comments
|
/sig node |
|
To clarify, 1000 Knative Services currently translates to about 2000 Cluster IP services and 1000 ExternalName services. |
|
One cause for bad performance with a large number of environment variables can be bash. This code seems to scale O(n^2) with number of variables, and is called on bash startup: https://github.com/bminor/bash/blob/d894cfd104086ddf68c286e67a5fb2e02eb43b7b/variables.c#L4197 |
|
Neither of the containers in question use bash as their entrypoint, both are built from |
|
@hanumanthan I'm not familiar with the K8s codebase to be able to point you to the right place. I'd probably reach out for help in the K8s slack - https://slack.k8s.io/ |
|
xref #93399 |
|
Issues go stale after 90d of inactivity. If this issue is safe to close now please do so with Send feedback to sig-testing, kubernetes/test-infra and/or fejta. |
|
/remove-lifecycle stale |
|
Could you provide a minimal reproducible example without Knative? @mattmoor @dprotaso |
|
Each service is ~8 env vars, typically with long names. Knative currently creates 2 ClusterIP and 1 ExternalName per service, and things failed for me at around 1200 Knative services. I don't think there's anything wrong with your repro except the numbers, I'd create 1200 ExternalName and 2400 ClusterIP services. |
|
Still can't repro, I have 1400 ExternalName and 2900 ClusterIP now. A potential slow startup reason is the container entrypoint trying to manipulate/scan env vars, such as Your time data comes from: This also calculates time from |
|
No, this was a pretty trivial Go HTTP server on GKE. |
|
Issues go stale after 90d of inactivity. If this issue is safe to close now please do so with Send feedback to sig-testing, kubernetes/test-infra and/or fejta. |
|
/lifecycle frozen |
|
/remove-lifecycle frozen since the issue needs more information, removing the freeze to make sure we are getting traction here. @mattmoor @dprotaso reading comments I see that the attempt to repro this failed. Can you please provide more information on how to repro this and why you believe the culprit is env variables. Also, what runtime do you use to run containers. /triage needs-information |
|
/lifecycle frozen Here's an example - with about ~1050 of these services (on a single node kind cluster) causes the deployment's container to fail to start apiVersion: v1
kind: Service
metadata:
generateName: long-name-name-name-name-long-name-name-name-name-long-name-nam
spec:
type: ClusterIP
ports:
- name: long-name-name-name-name-long-name-name-name-name-long-nam-http
port: 80
targetPort: 8080
- name: long-name-name-name-name-long-name-name-name-name-long-nm-https
port: 443
targetPort: 8443
- name: long-name-name-name-name-long-name-name-name-name-long-xmetricz
port: 9090
targetPort: 9090
- name: long-name-name-name-name-long-name-name-name-name-long-xhealthz
port: 9091
targetPort: 9091apiVersion: apps/v1
kind: Deployment
metadata:
name: some-deployment
spec:
replicas: 1
selector:
matchLabels:
app: app
template:
metadata:
labels:
app: app
spec:
containers:
- name: app
image: gcr.io/knative-samples/helloworld-go
ports:
- containerPort: 80containerd logs are If you see the original references issue you can mitigate this by disabling service links - but changing the default wasn't an option so hence I opened this performance tracking issue. Essentially the explosion of env vars causes massive runc configs to be written and you eventually hit some linux limits when starting the process. |
|
I had this issue recently on a customer cluster. There where too many services in a single namespace, which caused a bunch of env vars appearing on every pod. The problem might not be immediately apparent, but try running a timed workload (e.g. a bash script that performs sqrt() ) in that namespace and the same workload in a different namespace. For me, the difference was astronomical. Reason might be that any child process created needs to inherit all these env vars, and therefore, any type of workload that creates many child processes will suffer. My fix for this issue was to add |
|
Yeah, we opted to change the default in Knative over this. I doubt Kubernetes will make such a breaking change. |
|
They won't introduce the breaking change - that's why this issue is open. @SergeyKanzhelev this issue is tagged needs-information but you should have everything you need. Do you have any more questions? |
|
See also my comment: this issue particularly affects bash, which has a routine with O(n^2) complexity on the number of environment variables. It's easy to reproduce: create 1000+ services and do a 'kubectl exec' in a container that uses bash as entrypoint. I wish spec.template.spec.enableServiceLinks could be false by default in a Pod v2 definition. I feel like very few people use this functionality, but it affects the performance of all. Additionally, it would be great to improve bash to scale better by number of environment variables. |
Eventually all workloads fall over - my example doesn't use bash |
|
We had a lot of services in the same namespace.
|
|
It would be easier if this could be disable at the namespace level. |
|
same issue with knative, this cause latency running application, enableServiceLinks: false solved my probleme |
|
@dprotaso can you please check if |
|
@SergeyKanzhelev it does - we have that set by default in Knative. I believe I left this issue open so that it could be addressed - maybe in a future v2 of the Pod API |
|
/close duplicate of #121787 , were the solution has been discussed and proposed I'm almost certain this behavior will not be implemented for an hypothetical v2 Pod API 😄 |
|
@aojea: Closing this issue. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
From: #92226
What happened:
Having a modest number of services in your namespace will eventually degrade pod start time and after a certain number of services pods will fail to start.
What you expected to happen:
The number of services in a namespace should not prevent a pod from starting or degrade its start time.
How to reproduce it (as minimally and precisely as possible):
Example here: knative/serving#8498
Anything else we need to know?:
The culprit is the large list of env vars on pods coming from service links (which are on by default)
Environment:
kubectl version): 1.16The text was updated successfully, but these errors were encountered: