Skip to content

Inconsistent scaling #8390

Closed
Closed

Description

@duglin

In what area(s)?

/area autoscale

What version of Knative?

HEAD as of 6/20

Issue

Using this script:

$ cat doit
#!/bin/bash

set -e
PAUSE=${1:-10}
echo "Erasing old service"
kn service delete echo > /dev/null 2>&1 && sleep 5
URL=`kn service create echo --image duglin/echo --concurrency-limit=1 | tail -1`
echo "Service: $URL"
echo "Pause: $PAUSE"
for i in `seq 1 20` ; do
  echo -n "$i : Running 50... "
  (time (
    for i in `seq 1 50` ; do
      curl -s ${URL}?sleep=10 > /dev/null &
    done
    wait )
  ) 2>&1 | grep real | tr '\n' '\0'
  echo -n " # pods: "
  kubectl get pods | grep echo.*Running | wc -l
  sleep $PAUSE
done
kn service delete echo

It'll create a ksvc that just echos "hi", but will sleep based on a 'sleep' query param.
It'll then curl the service 50 times concurrently, telling it to sleep for 10 seconds, and print the # of pods and amount of time it took to run all 50. Ideally it should level out at 50 pods and around 10 seconds total for each set of 50 (20 sets are run).

I expect the first set, or two, of 50 to be a bit odd as it tries to get into a steady state, but after that it should remain fairly constant. When I run it with a pause of 0 seconds between each set of 50 I see this:

$ ./a 0
Erasing old service
Service: http://echo-default.kndev.us-south.containers.appdomain.cloud
Pause: 0
1 : Running 50... real  0m57.675s # pods: 33
2 : Running 50... real  0m20.185s # pods: 72
3 : Running 50... real  0m10.251s # pods: 72
4 : Running 50... real  0m10.203s # pods: 72
5 : Running 50... real  0m10.220s # pods: 72
6 : Running 50... real  0m10.239s # pods: 72
7 : Running 50... real  0m10.198s # pods: 72
8 : Running 50... real  0m10.184s # pods: 64
9 : Running 50... real  0m10.193s # pods: 64
10 : Running 50... real 0m10.225s # pods: 64
11 : Running 50... real 0m10.197s # pods: 64
12 : Running 50... real 0m10.179s # pods: 64
13 : Running 50... real 0m10.201s # pods: 68
14 : Running 50... real 0m10.205s # pods: 67
15 : Running 50... real 0m10.189s # pods: 68
16 : Running 50... real 0m10.197s # pods: 67
17 : Running 50... real 0m10.217s # pods: 67
18 : Running 50... real 0m10.213s # pods: 67
19 : Running 50... real 0m10.192s # pods: 67
20 : Running 50... real 0m10.175s # pods: 68
Service 'echo' successfully deleted in namespace 'default'.

which isn't too bad. ~65 pods seems a bit much, but at least I get a consistent 10 seconds per curl.

However, running with a delay of 10 seconds between each set of 50 I get this:

$ ./a
Erasing old service
Service: http://echo-default.kndev.us-south.containers.appdomain.cloud
Pause: 10
1 : Running 50... real  0m50.530s # pods: 58
2 : Running 50... real  0m10.208s # pods: 58
3 : Running 50... real  0m10.275s # pods: 58
4 : Running 50... real  0m10.252s # pods: 29
5 : Running 50... real  0m24.549s # pods: 29
6 : Running 50... real  0m20.214s # pods: 64
7 : Running 50... real  0m10.256s # pods: 64
8 : Running 50... real  0m10.275s # pods: 64
9 : Running 50... real  0m10.490s # pods: 29
10 : Running 50... real 0m20.353s # pods: 34
11 : Running 50... real 0m20.163s # pods: 56
12 : Running 50... real 0m11.501s # pods: 56
13 : Running 50... real 0m10.225s # pods: 56
14 : Running 50... real 0m25.116s # pods: 32
15 : Running 50... real 0m21.884s # pods: 46
16 : Running 50... real 0m12.542s # pods: 58
17 : Running 50... real 0m12.209s # pods: 59
18 : Running 50... real 0m20.200s # pods: 26
19 : Running 50... real 0m20.148s # pods: 32
20 : Running 50... real 0m20.151s # pods: 57
Service 'echo' successfully deleted in namespace 'default'.

It's weird that it drops down below 50 pods, ever. And because it does the timing I see for the curls doubles due to it queuing the requests.

I'm using default values for all auto-scaler options.

Activity

  1. added
    kind/bug
    on Jun 20, 2020
  2. duglin commented on Jun 20, 2020

    @duglin
    Author

    TBC=-1

    Pause: 10
    1 : Running 50... real  0m37.658s # pods: 72
    2 : Running 50... real  0m10.207s # pods: 72
    3 : Running 50... real  0m10.210s # pods: 72
    4 : Running 50... real  0m10.201s # pods: 36
    5 : Running 50... real  0m20.127s # pods: 40
    6 : Running 50... real  0m10.423s # pods: 72
    7 : Running 50... real  0m20.195s # pods: 28
    8 : Running 50... real  0m20.146s # pods: 36
    9 : Running 50... real  0m10.187s # pods: 57
    10 : Running 50... real 0m10.182s # pods: 69
    11 : Running 50... real 0m20.344s # pods: 29
    12 : Running 50... real 0m20.206s # pods: 30
    13 : Running 50... real 0m12.889s # pods: 54
    14 : Running 50... real 0m10.617s # pods: 65
    15 : Running 50... real 0m20.240s # pods: 30
    16 : Running 50... real 0m20.147s # pods: 33
    17 : Running 50... real 0m20.116s # pods: 53
    18 : Running 50... real 0m10.221s # pods: 72
    19 : Running 50... real 0m10.191s # pods: 72
    20 : Running 50... real 0m20.190s # pods: 28
    
  3. vagababov commented on Jun 21, 2020

    @vagababov
    Contributor
    1. Target utilization, so 50/0.7 is rounded up 72. Which looks correct.
    2. 10 seconds timeout is giving you at most 41 pods, but given the first run was 37s (last post) so in the minute you had at most 37s with 50 requests (at most) and 23 seconds with 0. That is at most 30 pods (you can add debugging to dump buckets to see actual numbers, but they are definitely smaller). So, it scales down, you hit it again, paying the price of cold starts.
      1. The first three runs you got 72 because of panic mode, so no scale down was incurred.
      2. Then it's just variation on the same theme.

    Depending on cold start variations the numbers change a bit.

  4. duglin commented on Jun 21, 2020

    @duglin
    Author

    I'm not sure if you're saying this is correct behavior or if there's something to be worked on.

    It appears as though pods are killed, in my env, after being idle for ~60 seconds. So, that would seem to indicate that if I send 50 requests (with CC=1) before that timeout then I should continually have (at least) 50 pods running. I understand the algorithm might not work that way today, but I suspect that might be the expectations people will have - I certainly did.

  5. mattmoor commented on Aug 17, 2020

    @mattmoor
    Contributor

    /assign @vagababov @markusthoemmes

    The discussion seems to be stalled after Doug's last question. If we're not going to fix, can we close this?

  6. vagababov commented on Aug 17, 2020

    @vagababov
    Contributor

    /assign @julz

    I think the latest we all kind of agreed to is to add mode that uses max rather avg as a scaling decision point.

  7. vagababov commented on Aug 18, 2020

    @vagababov
    Contributor

    /close
    In favor #8610

  8. knative-prow-robot commented on Aug 18, 2020

    @knative-prow-robot
    Contributor

    @vagababov: Closing this issue.

    Details

    In response to this:

    /close
    In favor #8610

    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.

  9. duglin commented on Aug 18, 2020

    @duglin
    Author

    @vagababov can you elaborate on why you think this is the same as #8610 ?

  10. vagababov commented on Aug 18, 2020

    @vagababov
    Contributor

    Since you see the behavior due to holes (no traffic). Which seems to correlate with that issue.
    But @julz filed another one, which is more precise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

area/autoscalekind/bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions