You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/container-apps/tutorial-scaling.md
+155-1Lines changed: 155 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,7 +5,7 @@ services: container-apps
5
5
author: craigshoemaker
6
6
ms.service: azure-container-apps
7
7
ms.topic: tutorial
8
-
ms.date: 02/03/2025
8
+
ms.date: 03/06/2025
9
9
ms.author: cshoe
10
10
ms.custom: devx-track-azurecli
11
11
ms.devlang: azurecli
@@ -90,6 +90,8 @@ Add an HTTP scale rule to your container app by running the `az containerapp upd
90
90
az containerapp update \
91
91
--name my-container-app \
92
92
--resource-group my-container-apps \
93
+
--min-replicas 1 \
94
+
--max-replicas 10 \
93
95
--scale-rule-name my-http-scale-rule \
94
96
--scale-rule-http-concurrency 1
95
97
```
@@ -100,6 +102,8 @@ az containerapp update \
100
102
az containerapp update `
101
103
--name my-container-app `
102
104
--resource-group my-container-apps `
105
+
--min-replicas 1 `
106
+
--max-replicas 10 `
103
107
--scale-rule-name my-http-scale-rule `
104
108
--scale-rule-http-concurrency 1
105
109
```
@@ -291,6 +295,156 @@ The following screenshot shows a zoomed view of how the requests received by you
291
295
292
296
:::image type="content" source="media/scale-app/azure-container-apps-scale-replicas-metrics-3.png" alt-text="Screenshot of container app metrics graph, showing requests split by replica, in a zoomed view.":::
293
297
298
+
## CPU and memory scaling
299
+
300
+
You should prefer [HTTP scaling rules](/azure/container-apps/scale-app#http) to CPU or memory scale rules when possible.
301
+
302
+
When you use the Azure CLI to add a scale rule to a container app that already has a scale rule, the new scale rule replaces the old scale rule. To see how to add multiple scale rules, see [Multiple scale rules](#multiple-scale-rules).
303
+
304
+
After you add a CPU or memory scale rule, you can test it by [sending requests to your container app](#send-requests) and [viewing the scaling in Azure portal](#view-scaling-in-azure-portal-optional).
305
+
306
+
### CPU scaling
307
+
308
+
CPU scaling allows your app to scale in or out depending on how much the CPU is being used. CPU scaling doesn't allow your container app to scale to 0. For more information about this trigger, see [KEDA CPU scale trigger](https://keda.sh/docs/scalers/cpu/).
309
+
310
+
Add a CPU scale rule to your container app by running the `az containerapp update` command. Replace the `<PLACEHOLDERS>` with your values. The CPU utilization value is the percentage of CPU utilization at which you want to scale your app.
Memory scaling allows your app to scale in or out depending on how much memory is being used. Memory scaling doesn't allow your container app to scale to 0. For more information about this trigger, see [KEDA memory scale trigger](https://keda.sh/docs/scalers/memory/).
343
+
344
+
Add a memory scale rule to your container app by running the `az containerapp update` command. Replace the `<PLACEHOLDERS>` with your values. The memory utilization value is the percentage of memory utilization at which you want to scale your app.
To add multiple scale rules to your container app using the Azure CLI, you must use YAML.
377
+
378
+
1. Export your container app configuration to YAML with the `az containerapp show` command.
379
+
380
+
# [Bash](#tab/bash)
381
+
382
+
```azurecli
383
+
az containerapp show \
384
+
--name my-container-app \
385
+
--resource-group my-container-apps \
386
+
--output yaml > app.yaml
387
+
```
388
+
389
+
# [PowerShell](#tab/powershell)
390
+
391
+
```powershell
392
+
az containerapp show `
393
+
--name my-container-app `
394
+
--resource-group my-container-apps `
395
+
--output yaml > app.yaml
396
+
```
397
+
398
+
---
399
+
400
+
1. In the `properties` > `template` > `scale` > `rules` section of `app.yaml`, add the following. Replace the `<PLACEHOLDERS>` with your values.
401
+
402
+
```yaml
403
+
...
404
+
properties:
405
+
...
406
+
template:
407
+
...
408
+
scale:
409
+
...
410
+
rules:
411
+
- name: cpu-scaling-rule
412
+
custom:
413
+
type: cpu
414
+
metadata:
415
+
type: "Utilization"
416
+
value: "<CPU_UTILIZATION>"
417
+
- name: memory-scaling-rule
418
+
custom:
419
+
type: memory
420
+
metadata:
421
+
type: "Utilization"
422
+
value: "<MEMORY_UTILIZATION>"
423
+
...
424
+
```
425
+
426
+
1. Import your container app configuration from `app.yaml` with the `az containerapp update` command.
427
+
428
+
# [Bash](#tab/bash)
429
+
430
+
```azurecli
431
+
az containerapp update \
432
+
--name my-container-app \
433
+
--resource-group my-container-apps \
434
+
--yaml app.yaml
435
+
```
436
+
437
+
# [PowerShell](#tab/powershell)
438
+
439
+
```powershell
440
+
az containerapp update `
441
+
--name my-container-app `
442
+
--resource-group my-container-apps `
443
+
--yaml app.yaml
444
+
```
445
+
446
+
---
447
+
294
448
## Clean up resources
295
449
296
450
If you're not going to continue to use this application, run the following command to delete the resource group along with all the resources created in this tutorial.
0 commit comments