One of the most crucial aspects in application hosting is how it can respond to variable load. During the lifetime of hosted applications, applications experience variability in load due to various reasons like seasonality, marketing events, etc. It is essential that our application can respond to such events successfully, without any impact on its SLA. But it is also not economical to hold huge amounts of hosting resources for seasonal and occasional variables in load. This is where autoscaler comes in. Autoscaler is a component which can trigger scale-up / scale down events in the kubernetes cluster to scale deployment, statefulsets and other such resources.
We can either scale horizontally (add more instances of the application) or vertically (make more resources available to the application). Typically, it’s more complicated to change the available resources for the pod in the kubernetes cluster. It’s quite easier to just scale one more / less replica of the application.
We have below options when it comes to scaling in kubernetes cluster
Today, we would see HPA and Keda in depth.
KEDA is a Kubernetes-based Event Driven Autoscaler. With KEDA, Kubernetes workloads can be autoscaled based on the number of events needing to be processed.
Internally, Keda uses HPA to delegate actual scaling up and scaling down operations. Keda really shines to scale the “processing” jobs based on onslaught of incoming load. E.g. Kafka Queue depth, AWS Kinesis Stream’s shard count, number of files in Azure blob storage. See here for all available Keda scalers. It is easy to also extend and write your own scaler which can react to events of your choice.
Keda defines a new Kubernetes Custom Resource (CR) – ScaledObject – which maps the Kubernetes Workload which needs to be scaled up/down with external triggers source which will trigger scale up/down.
To demonstrate simple event driven usage of keda – we will be creating a number of files in Azure blob storage. In the example below you will see The ScaledObject definition which will map nginx deployment as target with count of files in Azure Blob Storage as trigger source.
For more updates, follow us on LinkedIn, Twitter, Facebook, Instagram, and YouTube