Mastering Scaling Rules in Azure Container Apps
Scaling rules in Azure Container Apps exist to ensure your applications can handle varying loads without manual intervention. By setting these rules, you can automatically adjust the number of replicas based on real-time demand, which helps maintain performance and control costs. This is particularly vital in cloud environments where traffic can be unpredictable.
Azure Container Apps leverages KEDA (Kubernetes Event-driven Autoscaling) to manage scaling automatically. You define limits on the minimum and maximum number of replicas, and set rules that dictate when to add or remove these replicas. Key parameters include minReplicas (default 0) and maxReplicas (default 5). For HTTP scaling, you can specify concurrentRequests to determine when to scale out. Similarly, for TCP connections, you can use concurrentConnections. This flexibility allows you to tailor scaling behavior to your application's specific needs.
In production, be aware of some important considerations. You won't incur charges if your app scales to zero, but idle replicas may still incur lower costs. During platform upgrades, you might notice more replicas than expected. Also, scaling rules for Container Apps jobs are limited; they don’t support HTTP or TCP scaling rules. Ensure you understand these limitations to avoid unexpected behavior in your deployments.
Key takeaways
- →Define `minReplicas` and `maxReplicas` to control scaling limits effectively.
- →Utilize HTTP scaling rules with `concurrentRequests` to manage web traffic.
- →Implement TCP scaling rules using `concurrentConnections` for real-time applications.
- →Monitor for unexpected replicas during platform upgrades or maintenance.
- →Remember that idle replicas may still incur costs, albeit at a lower rate.
Why it matters
Effective scaling rules can significantly improve application responsiveness and reduce costs by ensuring resources are only used when needed. This is essential for maintaining performance during traffic spikes while avoiding unnecessary expenses.
Code examples
1resource symbolicname 'Microsoft.App/containerApps@2025-02-02-preview' = {
2 ...
3 properties: {
4 ...
5 template: {
6 ...
7 scale: {
8 maxReplicas: 0
9 minReplicas: 5
10 rules: [
11 name: 'http-rule'
12 http: {
13 metadata: {
14 concurrentRequests: '100'
151az containerapp create \
2 --name <CONTAINER_APP_NAME> \
3 --resource-group <RESOURCE_GROUP> \
4 --environment <ENVIRONMENT_NAME> \
5 --image <CONTAINER_IMAGE_LOCATION>
6 --min-replicas 0 \
7 --max-replicas 5 \
8 --scale-rule-name azure-http-rule \
9 --scale-rule-type http \
10 --scale-rule-http-concurrency 1001resource symbolicname 'Microsoft.App/containerApps@2025-02-02-preview' = {
2 ...
3 properties: {
4 ...
5 template: {
6 ...
7 scale: {
8 maxReplicas: 0
9 minReplicas: 5
10 rules: [
11 name: 'tcp-rule'
12 http: {
13 metadata: {
14 concurrentConnections: '100'
15When NOT to use this
The official docs don't call out specific anti-patterns here. Use your judgment based on your scale and requirements.
Want the complete reference?
Read official docsSimple, affordable cloud — VMs, Kubernetes, and managed databases in minutes. Trusted by 600,000+ developers. Spin up a Droplet in 60 seconds.
Try DigitalOcean →Mastering Ingress in Azure Container Apps: What You Need to Know
Ingress in Azure Container Apps is crucial for managing traffic to your applications. With options for external and internal ingress, you can control how your app is accessed. Learn about the nuances of HTTP and TCP ingress to optimize your deployment.
Mastering Azure Container Apps Environments: What You Need to Know
Azure Container Apps environments create a secure boundary for your applications, but understanding their nuances is crucial for effective deployment. Learn how workload profiles and virtual networks shape your app's behavior and security posture.
Leveraging Dapr in Azure Container Apps: A Game Changer for Microservices
Unlock the power of microservices with Azure Container Apps and Dapr. By configuring Dapr sidecars, you can streamline service communication via HTTP or gRPC, making your applications more resilient and scalable.
Get the daily digest
One email. 5 articles. Every morning.
No spam. Unsubscribe anytime.