Jump to content

Featured Replies

Posted

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.

 

 

 

691x357vv2.png.55590fc569c99191414100b45f0beccf.png

 

 

 

 

 

310x196vv2.png.7fe1946ed11fe6a91ca788f17d5900d9.png

 

682x361vv2.png.2f42b9e716a385486e79ee0785d02eed.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.

 

 

 

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

 

mediumvv2px400.png.9700c99d3e6601c3920688bbcecc34f7.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).

 

containerName - Name of the specific container to scale based on its memory, rather than the entire pod. Defaults to empty if not specified.

 

 

 

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

 

mediumvv2px400.png.4df0aa02aaa1d32e0f5de42cb1a9ea21.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).

 

containerName - Name of the specific container to scale based on its memory, rather than the entire pod. Defaults to empty if not specified.

 

 

 

Note – You can monitor the memory 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

 

 

 

mediumvv2px400.png.d5779420788c40349feb0660b96b011a.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.

 

mediumvv2px400.png.f24a1a829389e56fff5cb1f6d913fff2.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

 

Continue reading...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...