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
Azure Container Apps manages automatic horizontal scaling through a set of declarative scaling rules. As a container app scales out, new instances of the container app are created on-demand. These instances are known as replicas.
15
+
Azure Container Apps manages automatic horizontal scaling through a set of declarative scaling rules. As a container app scales out, new instances of the container app are created on-demand. These instances are known as replicas. When you first create a container app, the scale rule is set to zero. No charges are incurred when an application scales to zero.
16
16
17
-
Scaling rules are defined in `resources.properties.template.scale` section of the [configuration](overview.md). There are two scale properties that apply to all rules in your container app.
17
+
Scaling rules are defined in `resources.properties.template.scale` section of the JSON configuration file. When you add or edit existing scaling rules, a new revision of your container is automatically created with the new configuration. A revision is an immutable snapshot of your container app and it gets created automatically when certain aspects of your application are updated (scaling rules, Dapr settings, template configuration etc.). See the [Change types](./revisions.md#change-types) section to learn about the type of changes that do or don't trigger a new revision.
18
+
19
+
There are two scale properties that apply to all rules in your container app:
18
20
19
21
| Scale property | Description | Default value | Min value | Max value |
20
22
|---|---|---|---|---|
@@ -25,25 +27,29 @@ Scaling rules are defined in `resources.properties.template.scale` section of th
25
27
- Individual scale rules are defined in the `rules` array.
26
28
- If you want to ensure that an instance of your application is always running, set `minReplicas` to 1 or higher.
27
29
- Replicas not processing, but that remain in memory are billed in the "idle charge" category.
28
-
- Changes to scaling rules are a [revision-scope](overview.md) change.
30
+
- Changes to scaling rules are a [revision-scope](./revisions.md#revision-scope-changes) change.
29
31
- When using non-HTTP event scale rules, setting the `activeRevisionMode` to `single` is recommended.
30
32
31
33
> [!IMPORTANT]
32
34
> Replica quantities are a target amount, not a guarantee. Even if you set `maxReplicas` to `1`, there is no assurance of thread safety.
33
35
34
36
## Scale triggers
35
37
36
-
Container Apps supports a large number of scale triggers. For more information about supported scale triggers, see [KEDA Scalers](https://keda.sh/docs/scalers/).
38
+
Azure Container Apps supports the following scale triggers:
37
39
38
-
The KEDA documentation shows code examples in YAML, while the Container Apps ARM template is in JSON. As you transform examples from KEDA for your needs, make sure to switch property names from [kebab](https://en.wikipedia.org/wiki/Naming_convention_(programming)#Delimiter-separated_words) case to [camel](https://en.wikipedia.org/wiki/Naming_convention_(programming)#Letter_case-separated_words) casing.
40
+
-[HTTP traffic](#http): Scaling based on the number of concurrent HTTP requests to your revision.
41
+
-[Event-driven](#event-driven): Event-based triggers such as messages in an Azure Service Bus.
42
+
-[CPU](#cpu) or [Memory](#memory) usage: Scaling based on the amount of CPU or memory consumed by a replica.
39
43
40
44
## HTTP
41
45
42
46
With an HTTP scaling rule, you have control over the threshold that determines when to scale out.
43
47
44
48
| Scale property | Description | Default value | Min value | Max value |
45
49
|---|---|---|---|---|
46
-
|`concurrentRequests`| Once the number of requests exceeds this value, then more replicas are added, up to the `maxReplicas` amount. | 50 | 1 | n/a |
50
+
|`concurrentRequests`| Once the number of requests exceeds this then another replica is added. Replicas will continue to be added up to the `maxReplicas` amount as the number of concurrent requests increase. | 100 | 1 | n/a |
51
+
52
+
In the following example, the container app scales out up to five replicas and can scale down to zero. The scaling threshold is set to 100 concurrent requests per second.
47
53
48
54
```json
49
55
{
@@ -72,7 +78,30 @@ With an HTTP scaling rule, you have control over the threshold that determines w
72
78
}
73
79
```
74
80
75
-
In this example, the container app scales out up to five replicas and can scale down to zero instances. The scaling threshold is set to 100 concurrent requests per second.
81
+
### Add an HTTP scale trigger to a Container App in single-revision mode
82
+
83
+
> [!NOTE]
84
+
> Revisions are immutable. Changing scale rules automatically generates a new revision.
85
+
86
+
1. Open Azure portal, and navigate to your container app.
87
+
88
+
1. Select **Scale**, then select your revision from the dropdown menu.
:::image type="content" source="media/scalers/add-scale-rule.png" alt-text="A screenshot showing how to add a scale rule.":::
97
+
98
+
1. Select **HTTP scaling** and enter a **Rule name** and the number of **Concurrent requests** for your scale rule and then select **Add**.
99
+
100
+
:::image type="content" source="media/scalers/http-scale-rule.png" alt-text="A screenshot showing how to add an h t t p scale rule.":::
101
+
102
+
1. Select **Create** when you are done.
103
+
104
+
:::image type="content" source="media/scalers/create-http-scale-rule.png" alt-text="A screenshot showing the newly created http scale rule.":::
76
105
77
106
## Event-driven
78
107
@@ -82,6 +111,11 @@ Each event type features different properties in the `metadata` section of the K
82
111
83
112
The following example shows how to create a scale rule based on an [Azure Service Bus](https://keda.sh/docs/scalers/azure-service-bus/) trigger.
84
113
114
+
The container app scales according to the following behavior:
115
+
116
+
- For every 20 messages placed in the queue, a new replica is created.
117
+
- The connection string to the queue is provided as a parameter to the configuration file and referenced via the `secretRef` property.
118
+
85
119
```json
86
120
{
87
121
...
@@ -117,10 +151,135 @@ The following example shows how to create a scale rule based on an [Azure Servic
117
151
}
118
152
```
119
153
120
-
In this example, the container app scales according to the following behavior:
154
+
> [!NOTE]
155
+
> Upstream KEDA scale rules are defined using Kubernetes YAML, while Azure Container Apps supports ARM templates, Bicep Templates and Container Apps specific YAML. The following example uses an ARM template and therefore the rules need to switch property names from [kebab](https://en.wikipedia.org/wiki/Naming_convention_(programming)#Delimiter-separated_words) case to [camel](https://en.wikipedia.org/wiki/Naming_convention_(programming)#Letter_case-separated_words) when translating from existing KEDA manifests.
121
156
122
-
- As the messages count in the queue exceeds 20, new replicas are created.
123
-
- The connection string to the queue is provided as a parameter to the configuration file and referenced via the `secretRef` property.
157
+
### Set up a connection string secret
158
+
159
+
To create a custom scale trigger, first create a connection string secret to authenticate with the different custom scalers.
160
+
161
+
1. In Azure portal, navigate to your container app and then select **Secrets**.
162
+
163
+
1. Select **Add**, and then enter your secret key/value information.
164
+
165
+
1. Select **Add** when you are done.
166
+
167
+
:::image type="content" source="media/scalers/connection-string.png" alt-text="A screenshot showing how to create a connection string.":::
168
+
169
+
### Add a custom scale trigger
170
+
171
+
1. In Azure portal, select **Scale** and then select your revision from the dropdown menu.
172
+
173
+
:::image type="content" source="media/scalers/scale-revisions.png" alt-text="A screenshot showing the revisions scale page.":::
174
+
175
+
1. Select **Edit and deploy**.
176
+
177
+
1. Select **Scale**, and then select **Add**.
178
+
179
+
:::image type="content" source="media/scalers/add-scale-rule.png" alt-text="A screenshot showing how to add a scale rule.":::
180
+
181
+
1. Enter a **Rule name**, select **Custom** and enter a **Custom rule type**. Enter your **Secret reference** and **Trigger parameter** and then add your **Metadata** parameters. select **Add** when you are done.
182
+
183
+
:::image type="content" source="media/scalers/custom-scaler.png" alt-text="A screenshot showing how to configure a custom scale rule.":::
184
+
185
+
1. Select **Create** when you are done.
186
+
187
+
> [!NOTE]
188
+
> In multiple revision mode, adding a new scale trigger creates a new revision of your application but your old revision remains available with the old scale rules. Use the **Revision management** page to manage their traffic allocations.
189
+
190
+
### KEDA scalers conversion
191
+
192
+
Azure Container Apps supports KEDA ScaledObjects and all of the available [KEDA scalers](https://keda.sh/docs/scalers/). To convert KEDA templates, it's easier to start with a custom JSON template and add the parameters you need based on the scenario and the scale trigger you want to set up.
193
+
194
+
```json
195
+
{
196
+
...
197
+
"resources": {
198
+
...
199
+
"properties": {
200
+
"configuration": {
201
+
"secrets": [{
202
+
"name": "<YOUR_CONNECTION_STRING_NAME>",
203
+
"value": "<YOUR-CONNECTION-STRING>"
204
+
}],
205
+
},
206
+
"template": {
207
+
...
208
+
"scale": {
209
+
"minReplicas": "0",
210
+
"maxReplicas": "10",
211
+
"rules": [
212
+
{
213
+
"name": "<YOUR_TRIGGER_NAME>",
214
+
"custom": {
215
+
"type": "<TRIGGER_TYPE>",
216
+
"metadata": {
217
+
},
218
+
"auth": [{
219
+
"secretRef": "<YOUR_CONNECTION_STRING_NAME>",
220
+
"triggerParameter": "<TRIGGER_PARAMETER>"
221
+
}]
222
+
}
223
+
}]
224
+
}
225
+
```
226
+
227
+
The following is an example of setting up an [Azure Storage Queue](https://keda.sh/docs/scalers/azure-storage-queue/) scaler that you can configure to auto scale based on Azure Storage Queues.
228
+
229
+
Below is the KEDA trigger specification for an Azure Storage Queue. To set up a scale rule in Azure Container Apps, you will need the trigger `type` and any other required parameters. You can also add other optional parameters which vary based on the scaler you are using.
230
+
231
+
In this example, you need the `accountName` and the name of the cloud environment that the queue belongs to `cloud` to set up your scaler in Azure Container Apps.
> KEDA ScaledJobs are not supported. See [KEDA scaling Jobs](https://keda.sh/docs/concepts/scaling-jobs/#overview) for more details.
124
283
125
284
## CPU
126
285
@@ -201,9 +360,12 @@ The following example shows how to create a memory scaling rule.
201
360
## Considerations
202
361
203
362
- Vertical scaling is not supported.
363
+
204
364
- Replica quantities are a target amount, not a guarantee.
205
365
- Even if you set `maxReplicas` to `1`, there is no assurance of thread safety.
206
366
367
+
- If you are using [Dapr actors](https://docs.dapr.io/developing-applications/building-blocks/actors/actors-overview/) to manage states, you should keep in mind that scaling to zero is not supported. Dapr uses virtual actors to manage asynchronous calls which means their in-memory representation is not tied to their identity or lifetime.
0 commit comments