kedacore / http-add-on

Add-on for KEDA to scale HTTP workloads
https://kedacore.github.io/http-add-on/
Apache License 2.0
373 stars 97 forks source link

make PollingInterval configurable to speed up autoscaling reaction time #1184

Open lx1036 opened 4 weeks ago

lx1036 commented 4 weeks ago

Proposal

When create a HTTPScaledObject, operator will create a ScaledObject or skip creation, the ScaledObject PollingInterval field is a const 15:

const (
    soPollingInterval = 15

)

func NewScaledObject(
    namespace string,
    name string,
    labels map[string]string,
    annotations map[string]string,
    workloadRef v1alpha1.ScaleTargetRef,
    scalerAddress string,
    minReplicas *int32,
    maxReplicas *int32,
    cooldownPeriod *int32,
) *kedav1alpha1.ScaledObject {
    return &kedav1alpha1.ScaledObject{
        TypeMeta: metav1.TypeMeta{
            APIVersion: kedav1alpha1.SchemeGroupVersion.Identifier(),
            Kind:       ObjectKind(&kedav1alpha1.ScaledObject{}),
        },
        ObjectMeta: metav1.ObjectMeta{
            Namespace:   namespace,
            Name:        name,
            Labels:      labels,
            Annotations: annotations,
        },
        Spec: kedav1alpha1.ScaledObjectSpec{
            ScaleTargetRef: &kedav1alpha1.ScaleTarget{
                APIVersion: workloadRef.APIVersion,
                Kind:       workloadRef.Kind,
                Name:       workloadRef.Name,
            },
            PollingInterval: ptr.To[int32](soPollingInterval),
            CooldownPeriod:  cooldownPeriod,
            MinReplicaCount: minReplicas,
            MaxReplicaCount: maxReplicas,
            Advanced: &kedav1alpha1.AdvancedConfig{
                RestoreToOriginalReplicaCount: true,
            },
            Triggers: []kedav1alpha1.ScaleTriggers{
                {
                    Type: soTriggerType,
                    Metadata: map[string]string{
                        ScalerAddressKey:    scalerAddress,
                        HTTPScaledObjectKey: name,
                    },
                },
            },
        },
    }

It should be configurable like CooldownPeriod field, so When I speed up autoscaling reaction time, I can set PollingInterval=1, Keda external scaler get metrics every 1s.

Use-Case

No response

Is this a feature you are interested in implementing yourself?

Yes

Anything else?

No response