KEDA (Kubernetes Event-Driven Autoscaler) — Pod scaling based on external metrics (message queues, cron, HTTP).
HPA limitation: HPA only uses CPU/Memory. KEDA supports Kafka, RabbitMQ, Redis, SQS, etc.
Installation:
1helm repo add kedacore https://kedacore.github.io/charts2helm install keda kedacore/keda --namespace keda --create-namespace
ScaledObject for Kafka:
1apiVersion: keda.sh/v1alpha12kind: ScaledObject3metadata:4 name: kafka-consumer5 namespace: production6spec:7 scaleTargetRef:8 name: kafka-consumer9 minReplicaCount: 110 maxReplicaCount: 5011 triggers:12 - type: kafka13 metadata:14 bootstrapServers: kafka:909215 consumerGroup: my-group16 topic: orders17 lagThreshold: "100"18 - type: cron19 metadata:20 timezone: Europe/Moscow21 start: "0 8 * * 1-5"22 end: "0 20 * * 1-5"23 desiredReplicas: "5"
ScaledObject for RabbitMQ:
1- type: rabbitmq2 metadata:3 host: amqp://user:pass@rabbitmq:5672/4 queueName: tasks5 queueLength: "50"
Supported scalers: Kafka, RabbitMQ, Redis, AWS SQS, Azure Service Bus, Prometheus, Cron, HTTP, PostgreSQL, MySQL.