Scaling Applications in AKS

Azure Compute Solutions

Florin Angelescu

Azure Cloud Architect

Why scaling matters

 

Low Traffic

High Traffic

 

  • Applications rarely experience constant traffic:

    • Some hours may be quiet
    • Others bring spikes in usage
  • Without scaling:

    • Workloads risk becoming overloaded
    • Lead to poor performance or downtime
Azure Compute Solutions

Why scaling matters

 

Kubernetes

 

  • Kubernetes provides mechanisms to adjust resources dynamically.
  • Applications can handle demand efficiently.
  • Scaling ensures:
    • Users get consistent experiences
    • Organizations optimize costs
Azure Compute Solutions

Manual scaling

Manual Scaling

Increase or decrease the number of replicas in a deployment using kubectl scale.

Azure Compute Solutions

Manual scaling

Manual Scaling

Scaling a web app from two replicas to four:

  • Ensures more pods are available to serve requests
Azure Compute Solutions

Manual scaling

 

Manual Scaling

Manual Scaling

 

 

Useful for:

  • Planned product launches
  • Promotions
  • Stock sales
Azure Compute Solutions

Horizontal Pod Autoscaler (HPA)

HPA

Azure Compute Solutions

Horizontal Pod Autoscaler (HPA)

HPA

Monitors metrics (CPU and memory usage) then automatically adjusts the number of replicas.

Azure Compute Solutions

Horizontal Pod Autoscaler (HPA)

HPA

Usage rises above a threshold:

  • More pods are created
Azure Compute Solutions

Horizontal Pod Autoscaler (HPA)

HPA

Demand falls:

  • Pods are removed
Azure Compute Solutions

Horizontal Pod Autoscaler (HPA)

HPA

  • Integrates with Azure Monitor.
  • Allows custom metrics (request latency, queue length).
Azure Compute Solutions

Cluster Autoscaler

 

Autoscaler

 

 

  • Adds or removes nodes based on demand.
  • Pods cannot be scheduled due to insufficient resources:
    • New nodes are provisioned automatically
Azure Compute Solutions

Cluster Autoscaler

 

Autoscaler

 

 

  • Demand decreases:

    • Unused nodes are removed to save costs
  • Infrastructure matches workload needs:

    • Without over-provisioning
Azure Compute Solutions

Best practices for scaling

Metrics

Define realistic resource requests and limits

Combine

Combine Horizontal Pod Autoscaler with Cluster Autoscaler

Test

Test scaling behavior under load

Cost

Monitor costs

Azure Compute Solutions

Recap

 

Kubernetes

  • Scaling in AKS ensures applications adapt to demand automatically:
    • Manual scaling
    • Horizontal Pod Autoscaler
    • Cluster Autoscaler
  • Balance performance and efficiency.
Azure Compute Solutions

Let's practice!

Azure Compute Solutions

Preparing Video For Download...