Skip to content

Autoscaler scales app to less than activation-scale #14017

Closed

Description

@diarmuidie

What version of Knative?

1.10.0

Expected Behavior

Services with activation-scale of "2" and initial-scale of "2" should always have at least two replicas running when not scaled to zero. e.g. when deployed the service will initially go to two replicas then if it receives no traffic for the scale to zero period it will go from 2 replicas to zero.

I'm not sure if this is strictly a bug or my misunderstanding of the expected outcome based on this description:

// ActivationScale is the minimum, non-zero value that a service should scale to.
// For example, if ActivationScale = 2, when a service scaled from zero it would
// scale up two replicas in this case. In essence, this allows one to set both a
// min-scale value while also preserving the ability to scale to zero.
// ActivationScale must be >= 2.
ActivationScaleKey = GroupName + "/activation-scale"

ActivationScale is the minimum, non-zero value that a service should scale to.

Actual Behavior

Initially the service will correctly scale up to 2 replicas but if it does not receive traffic for the scale down period it will scale down to one replica before finally scaling to zero replicas.

If the service receives traffic (even one request) when one replica is running it will scale back up to two replicas.

Steps to Reproduce the Problem

Create a service with the following annotations:

    autoscaling.knative.dev/activation-scale: "2"
    autoscaling.knative.dev/initial-scale: "2"

Allow the service to scale down (by receiving no traffic)

Activity

  1. dprotaso commented on May 26, 2023

    @dprotaso
    Member

    /triage accepted

    What I observed:

    When creating the new Knative service

    1. The number of initial pods was correct (matches initial-scale)
    2. The autoscaler immediately scaled down to one pod (incorrect)
    3. It eventually scaled zero

    When sending traffic

    1. The correct number of pods scaled up (matches activation-scale)
    2. After 60s (stable window?) it scaled down to one pod (incorrect)
    3. After another 30s it terminated the last pod

    cc @psschwei in case you have input

  2. xtreme-vikram-yadav commented on May 26, 2023

    @xtreme-vikram-yadav
  3. added this to the v1.11.0 milestone on May 27, 2023
  4. skonto commented on May 29, 2023

    @skonto
    Contributor

    +1 I have seen this too when trying that feature. I could not reproduce the expected behavior (but was not sure if I was missing anything).

  5. psschwei commented on May 30, 2023

    @psschwei
    Member

    Does the scale down from 2 --> 1 --> 0 happen every time, or just the first time? If it's just the first time, then the issue might be with initial scale.

    From the release notes: Note that the initial target scale for a revision is still handled by initial-scale; activation-scale will only apply on subsequent scales from zero.

    (I think that got written after the code merged, but probably not a bad idea to update the comment to include that info)

    It could also be that activation-scale only applies when scaling up... it's been a while and most of the discussion of this was on the old slack instance. That seems to sound right, based on what I remember, but again, it's been a while...

  6. diarmuidie commented on May 31, 2023

    @diarmuidie
    Author

    Does the scale down from 2 --> 1 --> 0 happen every time, or just the first time?

    Confirmed that it happens every time (when the revision isn't getting traffic), not just the first time.

    From the release notes: Note that the initial target scale for a revision is still handled by initial-scale; activation-scale will only apply on subsequent scales from zero.

    In my test case I have both initial-scale and activation-scale are set to 2.

  7. psschwei commented on May 31, 2023

    @psschwei
    Member

    Looking at the docs for activation-scale (link), it seems that the intention was to cover just the scale up case (in other words, an initial scale that would be applied when scaling from zero).

    For initial scale, we have the following in the docs: " After the Revision has reached this scale one time, this value is ignored. This means that the Revision will scale down after the initial target scale is reached if the actual traffic received only needs a smaller scale." It might make sense to add that to the activation scale section as well.

    All that said, I'm in no way opposed to changing activation scale to expected behavior raised in this issue if that's what folks would prefer.

  8. xtreme-vikram-yadav commented on Jun 20, 2023

    @xtreme-vikram-yadav

    I think documenting the current behaviour of activation-scale should suffice. Leaving the scale down decision to autoscaler makes sense unless there is a specific use case for support scaling down to zero by the value of activation-scale.

    @diarmuidie are you currrently affected by this or would improved documentation suffice?

  9. removed their assignment
    on Jul 10, 2023
  10. modified the milestones: v1.11.0, v1.12.0 on Aug 16, 2023
  11. modified the milestones: v1.12.0, Icebox on Nov 21, 2023
  12. dprotaso commented on Nov 21, 2023

    @dprotaso
    Member

    @diarmuidie following up are you affected by the current behaviour?

    We've done the documentation but it does not mean we shouldn't change it to be more 'intuitive' obvious.

  13. diarmuidie commented on Apr 22, 2024

    @diarmuidie
    Author

    Sorry about the delay, I somehow missed your comments. LGTM. Thanks for the doc update @dprotaso and @xtreme-vikram-yadav 👍

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/autoscalekind/bugCategorizes issue or PR as related to a bug.triage/acceptedIssues which should be fixed (post-triage)

    Type

    No type

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions