-
Notifications
You must be signed in to change notification settings - Fork 40k
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
get pods blocks 7-10 seconds if pods are being created at the same time #4196
Comments
I run some experiments and I kind-of reproduced this problem. I run in one terminal for N-s from 10 to 100. It was the case that get pods was running for 6-7 seconds on average, but it wasn't noticeably increasing with N (which I guess is interesting). I'm not very sure of those results though, because kubectl was having problems with starting/stopping more than ~30 pods in background. It was failing some starts (~5%) and a lot of stops. Number of failed stops was drastically increasing with N, which may be caused by the cluster overload (I have 4 minions in it), but I'm not familiar enough with architecture if know if it's expected or not. |
I'm not sure if I correctly understood the code, so please correct me if I'm wrong. My take is that this kind of behaviour is inherent for current implementation. IIUC the workflow for 'get pods' calls List method from pod/rest.go consists roughly of two steps: getting the list of the pods from etcd in the form of running ListPodsPredicate(..) and then running GetPodStatus on PodCache for each pod returned by List... (I wasn't able to find implementation of registry other than etcd one). I added additional logging and found out that etcd queries, are fast enough (~0.1-0.2 sec), but going through the cache is pretty slow (easily over 2 sec). I'm not sure what's taking so long, but I suspect some lock congestion. |
Get pods generally have a HUGE variance in a running time (easily from 1.5 to 6 sec) on the same cluster state, so I don't think create/get interaction is to blame, but the get itself is problematic. Profiling APIserver does not show anything interesting, as roughly all the CPU time is used by JSON handling. I analyzed logs with additional debug info added, and now, contrary to my previous comment, found slow etcd reads:
This shows that we loose most of the time in getting single pod in the This leaves us with a couple of questions: why there were 52 nodes to process there, can it be parallelelized and why it took 42 ms to process a single one. |
Someone brought into my attention the fact, that by default on GCE we run on single thread. This means that even if there are multiple HTTP servers running in separate go routines, physically they run interleaved on a single thread. This means that doing few things in the same time has to make everything noticeably slower, but maybe not to this magnitude. But if we add the fact that on the same machine there's a lot other things running (etcd, replication controllers) it's starts to be close. I run an experiment with 4 thread master, which reduced latency by ~33% for pretty much everything I checked, but still, once in a while, some calls took much more time to finish. |
Yes, we should run with multiple threads. Also, rather than just profiling cpu time, it may be more useful to profiling blocking time.
|
Yeah, I suspect the problem is mostly contention for a lock or etcd or RPCs. Adding a pod causes multiple etcd read/writes, as scheduler will be watching and (hopefully) quickly bind the pod. |
I looked at contention profiles but found nothing interesting. |
This would be good to add to our metrics for #4521 |
FYI: I was trying to reproduce this problem last week and failed. |
I expect that this is fixed now that we removed boundPods. I'll close this since gmarek couldn't repro. |
If I fire off 20 create pod requests (in the background), then issue a get pods request, the api server becomes unresponsive for 7-10 seconds.
% time kubectl --server=https://130.211.162.155 --auth-path=/usr/local/google/home/mohr/.config/gcloud-dogfood/kubernetes/mohr-instance-manager.us-central1-f.prod10d/kubernetes_auth --insecure-skip-tls-verify=true get pods
^[[A
POD IP CONTAINER(S) IMAGE(S) HOST LABELS STATUS
pause-pod-146e9dc7 pause-pod-146e9dc7 kubernetes/pause k8s-prod10d-node-1.c.mohr-instance-manager.internal/ name=pause-pod-146e9dc7 Unknown
pause-pod-39afa37d 10.32.2.89 pause-pod-39afa37d kubernetes/pause k8s-prod10d-node-3.c.mohr-instance-manager.internal/146.148.87.193 name=pause-pod-39afa37d Pending
pause-pod-43531a69 10.32.1.90 pause-pod-43531a69 kubernetes/pause k8s-prod10d-node-2.c.mohr-instance-manager.internal/130.211.164.97 name=pause-pod-43531a69 Pending
pause-pod-4d6b99cb 10.32.0.78 pause-pod-4d6b99cb kubernetes/pause k8s-prod10d-node-1.c.mohr-instance-manager.internal/104.154.60.240 name=pause-pod-4d6b99cb Pending
pause-pod-66cb6cc0 10.32.0.80 pause-pod-66cb6cc0 kubernetes/pause k8s-prod10d-node-1.c.mohr-instance-manager.internal/104.154.60.240 name=pause-pod-66cb6cc0 Pending
pause-pod-96aaba36 10.32.1.88 pause-pod-96aaba36 kubernetes/pause k8s-prod10d-node-2.c.mohr-instance-manager.internal/130.211.164.97 name=pause-pod-96aaba36 Pending
pause-pod-97b03e05 10.32.2.93 pause-pod-97b03e05 kubernetes/pause k8s-prod10d-node-3.c.mohr-instance-manager.internal/146.148.87.193 name=pause-pod-97b03e05 Running
pause-pod-b9709ceb pause-pod-b9709ceb kubernetes/pause k8s-prod10d-node-2.c.mohr-instance-manager.internal/130.211.164.97 name=pause-pod-b9709ceb Unknown
pause-pod-c752b5c2 pause-pod-c752b5c2 kubernetes/pause k8s-prod10d-node-3.c.mohr-instance-manager.internal/146.148.87.193 name=pause-pod-c752b5c2 Unknown
pause-pod-eb5ecc36 10.32.1.91 pause-pod-eb5ecc36 kubernetes/pause k8s-prod10d-node-2.c.mohr-instance-manager.internal/130.211.164.97 name=pause-pod-eb5ecc36 Running
pause-pod-ebd98025 10.32.1.92 pause-pod-ebd98025 kubernetes/pause /130.211.164.97 name=pause-pod-ebd98025 Pending
pause-pod-f5aeaee3 10.32.2.92 pause-pod-f5aeaee3 kubernetes/pause k8s-prod10d-node-3.c.mohr-instance-manager.internal/146.148.87.193 name=pause-pod-f5aeaee3 Running
pause-pod-f698b56f 10.32.2.90 pause-pod-f698b56f kubernetes/pause k8s-prod10d-node-3.c.mohr-instance-manager.internal/146.148.87.193 name=pause-pod-f698b56f Running
skydns-fplln 10.32.0.3 etcd quay.io/coreos/etcd:latest k8s-prod10d-node-1.c.mohr-instance-manager.internal/104.154.60.240 k8s-app=skydns Running
kube2sky kubernetes/kube2sky:1.0
skydns kubernetes/skydns:2014-12-23-001
0.038u 0.011s 0:07.63 0.5% 0+0k 0+0io 0pf+0w
(or http://pastebin.com/Z5JipRhB)
If I issue a "get pod skydns-fplln", the api request doesn't seem to block.
The text was updated successfully, but these errors were encountered: