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/dapr-keda-scaling.md
+25-43Lines changed: 25 additions & 43 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,24 +5,34 @@ author: hhunter-ms
5
5
ms.author: hannahhunter
6
6
ms.service: container-apps
7
7
ms.topic: how-to
8
-
ms.date: 04/07/2023
8
+
ms.date: 04/10/2023
9
9
---
10
10
11
11
# Scale Dapr components with KEDA scalers for Azure Container Apps
12
12
13
-
When scale rules are omitted on an Azure Container Apps resource, the container app is created with a default scale rule. If the resource receives no incoming traffic over a duration of five minutes, that default rule scales all replicas down to zero.
13
+
When scale rules are omitted on an Azure Container Apps resource, the container app is created with a default scale rule. If the resource receives no incoming traffic over a duration of five minutes, that default rule scales all replicas down to zero. This behavior can be problematic and unexpected when leveraging Dapr components, specifically pub/sub subscriptions and input bindings.
14
14
15
-
This behavior can be problematic and unexpected when leveraging Dapr components, specifically pub/sub subscriptions and input bindings. This is due to how the mechanism for subscriptions and input bindings work. Unlike normal http flows, subscriptions and input bindings follow a "pull" message/event exchange model. In this case the Dapr sidecar from the subscriber service "pulls" messages rather than waiting for the message broker/event deliverer to initiate a connection. As a result, since the "puller" logic is in the Dapr sidecar, when it scales down to zero, the "puller" is stopped and there's no mechanism for it to know when to resume or scale back up from zero.
15
+
Using KEDA scalers, you can scale your application and its Dapr sidecar when it has scaled to zero with inbound events and messages. However, configuring _both_ a Dapr component and a corresponding KEDA scaler is not intuitive.
16
16
17
-
KEDA scalers is one possible solution for scaling an application and its sidecar when it has scaled to 0 and incoming events and messages are inbound. With KEDA, there is a process that's outside of the application, which is never scaled down to zero that can wawtch for new messages/incoming events. It can then scale the receiving application as needed based on the number of incoming messages/events.
17
+
todo: solution - if it's redundant or complex, then why?
18
18
19
-
However, there is complexity and redudancncy with the experience that is offered today. A Dapr component and a corresponding KEDA scaler are two separate configurations and it's not intuative that a KEDA scaler is often needed.
19
+
## Configure container apps for scaling
20
20
21
-
The following scenario outlines a simple scenario with two microservices - a publisher and subscriber. In a loop, the publisher is continuously publishing messages via the Dapr pub/sub API to the topic ‘orders’ in Azure Service Bus. The order-processor container app is subscribed to the ‘orders’ topic and is receiving and processing the messages as they arrive.
21
+
In this scenario:
22
+
1. In a loop, a `checkout` publisher container app continuously publishes messages via the Dapr pub/sub API to the `orders` topic in Azure Service Bus.
23
+
1. An `order-processor` subscriber container app subscribed to the `orders` topic receives and processes messages as they arrive.
22
24
23
-
Let’s look at the Bicep for both Container Apps – the checkout and order-processor service as well as the Dapr Azure Serivce Bus component:
25
+
Let’s look at the Bicep for:
26
+
- The `checkout` and `order-processor` container apps
27
+
- The Dapr Azure Serivce Bus component
24
28
25
-
#### Checkout Container App (Publisher)
29
+
todo: need actual steps - so far it's more of a scenario concept, user isn't walking through any steps.
30
+
31
+
### Publisher container app
32
+
33
+
The `checkout` publisher is a headless services that you want to run indefinitely and never scale down to zero.
34
+
35
+
Set the `minReplicas` to "1", which ensures the container app does not follow the default behavior.
Since the checkout container app is a headless services that we want to run indefinitely and never scale down to 0, we are setting the min replicas to 1, which ensures the container app does not follow the default behavior of scaling to 0 after 5 minutes.
93
+
### Dapr component
84
94
85
-
Next, we will look at the configuration for the Dapr component for connecting to Azure Service Bus:
95
+
Next, configure the Dapr component for connecting to Azure Service Bus via a connection string.
In the above example, the component is configured to connect to Azure Service Bus via a connection string.
116
-
117
-
Lastly, we'll review the `order-processor` container app:
124
+
### Subscriber container app
118
125
119
-
#### Order-Processor Container App (Subscriber)
126
+
In the `order-processor` subscriber, you'll add a custom scale rule on the resource for the type `azure-servicebus`. With this scale rule, KEDA can scale up the container app and its Dapr sidecar, allowing incoming messages to be processed again while order-processor is scaled to zero.
This is a custom scale rule for the type “azure-servicebus”. This scale rule is needed to ensure that when a message comes into the Azure Service Bus while the order-processor is scaled to 0, that KEDA can scale up the container app, along with its Dapr sidecar so messages can be processed again.
219
+
[Learn more about using Dapr components with Azure Container Apps.](./dapr-overview.md)
0 commit comments