Scaling options in Azure Container Apps
Published Jul 19 2023 11:29 PM 12.5K Views
Microsoft

Azure Container Apps is a fully managed environment that enables you to run microservices and containerized applications on a serverless platform, which manages automatic horizontal scaling through a set of declarative scaling rules. As a container app revision scales out, new instances of the revision are created on-demand. These instances are known as replicas.

Adding or editing scaling rules creates a new revision of your container app. A revision is an immutable snapshot of your container app. 

 

Scaling is driven by different categories of triggers - this blog discusses HTTP and Custom triggers. 

 

HTTP SCALING

With an HTTP scaling rule, you have control over the threshold of concurrent HTTP requests that determines how your container app revision scales.

Navigate to Container App > Scale and replicas > Scale > Edit and deploy > Scale > Add Scale rule to configure scaling rules.
HTTP traffic: These rules will scale the container app based on the number of concurrent HTTP requests to your container app.

 

haricky_0-1689763768869.png

 

 

haricky_1-1689763768871.png

haricky_2-1689763768881.png

 

Note – You can utilize the Request Metric to check the number of requests in the metrics, as shown above.

 

CUSTOM SCALING
You can create a custom Container Apps scaling rule based on any ScaledObject-based KEDA scaler.

NOTE: Metadata parameters are case-sensitive. Inaccuracies may affect functionality or cause errors, so attention to detail is crucial.

 

1. Configure Scale rules based on Memory Usage under Custom Rule –

The rules will scale the container app based on the amount of Memory consumption.

Custom rule type: memory Reference: Memory | KEDA

haricky_4-1689764127601.png

 

Parameter List –

type - Type of metric to use. Options are Utilization, or AverageValue.

value - Value to trigger scaling actions for:

  • When using Utilization, the target value is the average of the resource metric across all relevant pods, represented as a percentage of the requested value of the resource for the pods.
  • When using AverageValue, the target value is the target value of the average of the metric across all relevant pods (quantity).

Note – You can monitor the memory consumption in DASP to validate the activation of the auto-scaling rules.

 

2. Configure Scale rules based on CPU Usage under Custom Rule –

The rules will scale the container app based on the amount of CPU consumption.

Custom rule type: cpu Reference: CPU | KEDA

haricky_5-1689764127603.png

 

 

Parameter List –

type - Type of metric to use. Options are Utilization, or AverageValue.

value - Value to trigger scaling actions for:

  • When using Utilization, the target value is the average of the resource metric across all relevant pods, represented as a percentage of the requested value of the resource for the pods.
  • When using AverageValue, the target value is the target value of the average of the metric across all relevant pods (quantity).

Note – You can monitor the CPU consumption in DASP to validate the activation of the auto-scaling rules.

 

3. Configure Scale rules based on Azure Service Bus Queues or Topics-

This rule will scale the container app replicas based on the number of messages in the Azure Service Bus Queue or Topic.

Custom rule type: azure-servicebus Reference: Azure Service Bus | KEDA

 

haricky_6-1689764127605.png

 

 

Parameter List –

connection – this is an Authentication Parameter which has the connection string for the Azure Service Bus Namespace. The following formats are supported.

  • With SharedAccessKey - Endpoint=sb://<sb>.servicebus.windows.net/;SharedAccessKeyName=<key name>;SharedAccessKey=<key value>
  • With SharedAccessSignature -
    Endpoint=sb://<sb>.servicebus.windows.net/;SharedAccessSignature=SharedAccessSignature sig=<signature-string>&se=<expiry>&skn=<keyName>&sr=<URL-encoded-resourceURI>

messageCount- Amount of active messages in your Azure Service Bus queue or topic to scale on. Default: 5 messages

namespace- Name of the Azure Service Bus namespace that contains your queue or topic.

queueName- Name of the Azure Service Bus queue to scale on.

(or)

topicName- Name of the Azure Service Bus topic to scale on.

 

Note- To monitor the messages in the queue or topic, navigate to the Service Bus resource and view the metrics.

 

4. Configure Scale rules based on Azure Blob Storage-

This rule will scale the container app replicas based on the count of blobs in a given Azure Blob Storage container.

Custom rule type: azure-blob Reference: Azure Blob Storage | KEDA

NOTE: This requires you to setup an environment variable on the replica you are configuring the scale rule with value of the connection string of the storage account. For this, you will need to create a secret and use this secret in the environment variable.

haricky_7-1689764127608.png

 

Parameter List –

connection – this is an Authentication Parameter which has the Connection string for Azure Storage Account. The following format is supported for the connection string (to be specified at the secret/environment variable).

DefaultEndpointsProtocol=https;AccountName=<storage-account>;AccountKey=<key>;EndpointSuffix=core.windows.net

 

blobContainerName - Name of container in an Azure Storage account.

blobCount - Average target value to trigger scaling actions. (Default: 5, Optional)

activationBlobCount- Target value for activating the scaler. (Default: 0, Optional)

connectionFromEnv- Name of the environment variable your deployment uses to get the connection string.

accountName- Name of the storage account that the container belongs to.

 

Note- To monitor the blobs in the container, navigate to the container in the storage account.

 

SCALING BEHAVIOR

This video explains how scaling works in Container Apps with an example:

 

REFERENCE
Scaling in Azure Container Apps | Microsoft Learn

Version history
Last update:
‎Nov 13 2023 10:33 PM
Updated by: