Cron Triggers
Kubernetes-based Event-Driven Autoscaler (KEDA) supports Cron triggers, enabling the configuration of periodic scheduled scaling with Cron expressions. For details, please refer to KEDA Scalers: Cron. Cron triggers are suitable for businesses with periodic characteristics, such as business traffic with fixed periodic peaks and troughs.
Use Cases
Daily Fixed-time Flash Sales Activities
The characteristic of a flash sales activity is that the time is relatively fixed, allowing for scaling out in advance before the activity begins. Below is an example configuration of ScaledObject
.
apiVersion: keda.sh/v1alpha1
kind: ScaledObject
metadata:
name: seckill
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: seckill
pollingInterval: 15
minReplicaCount: 2
maxReplicaCount: 1000
advanced:
horizontalPodAutoscalerConfig:
behavior:
scaleDown:
stabilizationWindowSeconds: 600
policies:
- type: Percent
value: 100
periodSeconds: 15
scaleUp:
policies:
- type: Percent
value: 500
periodSeconds: 15
triggers:
- type: cron
metadata:
timezone: Asia/Shanghai
start: 30 9 * * *
end: 30 10 * * *
desiredReplicas: "200"
- type: cron
metadata:
timezone: Asia/Shanghai
start: 30 17 * * *
end: 30 18 * * *
desiredReplicas: "200"
- type: memory
metricType: Utilization
metadata:
value: "60"
- type: cpu
metricType: Utilization
metadata:
value: "60"
Notes
Usually, the triggers cannot be configured with Cron alone and need to be used in conjunction with other triggers. This is because if no other triggers are active outside the Cron's start and end interval, the number of replicas will drop to minReplicaCount
.
Was this page helpful?