Skip to content

Commit 15fa33a

Browse files
authored
content for Configure independent autoscaling
1 parent 2608f69 commit 15fa33a

File tree

1 file changed

+27
-24
lines changed

1 file changed

+27
-24
lines changed

docs/aac/java-mwa-guide.md

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -372,41 +372,44 @@ To configure authentication and authorization on users (*user identities*), foll
372372

373373
The Modern Web App pattern begins breaking up the monolithic architecture and introduces service decoupling. When you decouple a web app architecture, you can scale decoupled services independently. Scaling the Azure services to support an independent web app service, rather than an entire web app, optimizes scaling costs while meeting demands. To autoscale containers, follow these recommendations:
374374

375-
- *Use stateless services.* Ensure your services are stateless. If your .NET application contains in-process session state, externalize it to a distributed cache like Redis or a database like Azure SQL Server.
375+
- *Use stateless services.* Ensure your services are stateless. If your web app contains in-process session state, externalize it to a distributed cache like Redis or a database like Azure SQL Server.
376376

377377
- *Configure autoscaling rules.* Use the autoscaling configurations that provide the most cost-effective control over your services. For containerized services, consider event-based scaling, such as Kubernetes Event-Driven Autoscaler (KEDA) often provides granular control, allowing you to scale based on event metrics. [Azure Container Apps](/azure/container-apps/scale-app) and Azure Kubernetes Service support KEDA. For services that don't support KEDA, such as [Azure App Service](/azure/app-service/manage-automatic-scaling), use the autoscaling features provided by the platform itself. These features often include scaling based on metrics-based rules or HTTP traffic.
378378

379379
- *Configure minimum replicas.* To prevent a cold start, configure autoscaling settings to maintain a minimum of one replica. A cold start is when you initialize a service from a stopped state, which often creates a delayed response. If minimizing costs is a priority and you can tolerate cold start delays, set the minimum replica count to 0 when configuring autoscaling.
380380

381381
- *Configure a cooldown period.* Apply an appropriate cooldown period to introduce a delay between scaling events. The goal is to [prevent excessive scaling](/azure/well-architected/cost-optimization/optimize-scaling-costs#optimize-autoscaling) activities triggered by temporary load spikes.
382+
382383
- *Configure queue-based scaling.* If your application uses a message queue like Azure Service Bus, configure your autoscaling settings to scale based on the length of the queue with request messages. The scaler aims to maintain one replica of the service for every N message in the queue (rounded up).
383384

384-
For example, the reference implementation uses the [Azure Service Bus KEDA scaler](/azure/container-apps/scale-app) to scale the Container App based on the length of the queue. The `service-bus-queue-length-rule` scales the service based on the length of a specified Azure Service Bus queue. The `messageCount` parameter is set to 10, so the scaler has one service replica for every 10 messages in the queue. The `scaleMaxReplicas` and `scaleMinReplicas` parameters set the maximum and minimum number of replicas for the service. The `queue-connection-string secret`, which contains the connection string for the Service Bus queue, is retrieved from Key Vault. This secret is used to authenticate the scaler to the Service Bus.
385-
386-
```yml
387-
scaleRules: [
388-
{
389-
name: 'service-bus-queue-length-rule'
390-
custom: {
391-
type: 'azure-servicebus'
392-
metadata: {
393-
messageCount: '10'
394-
namespace: renderRequestServiceBusNamespace
395-
queueName: renderRequestServiceBusQueueName
385+
For example, the reference implementation uses the **Azure Service Bus KEDA** scaler to automatically scale the **Azure Container App** based on the length of the Azure Service Bus queue. The scaling rule, named `service-bus-queue-length-rule`, adjusts the number of service replicas depending on the message count in the specified Azure Service Bus queue.
386+
387+
In this configuration:
388+
- The `messageCount` parameter is set to 10, which means the scaler will add one replica for every 10 messages in the queue.
389+
390+
- The **maximum replicas** (`max_replicas`) are set to 10, and minimum replicas are implicitly 0 unless overridden, which allows the service to scale down to zero when there are no messages in the queue.
391+
392+
- The connection string for the Service Bus queue is stored securely as a secret in Azure, named `azure-servicebus-connection-string`, which is used to authenticate the scaler to the Service Bus.
393+
394+
```terraform
395+
max_replicas = 10
396+
min_replicas = 1
397+
398+
custom_scale_rule {
399+
name = "service-bus-queue-length-rule"
400+
custom_rule_type = "azure-servicebus"
401+
metadata = {
402+
messageCount = 10
403+
namespace = var.servicebus_namespace
404+
queueName = var.email_request_queue_name
405+
}
406+
authentication {
407+
secret_name = "azure-servicebus-connection-string"
408+
trigger_parameter = "connection"
396409
}
397-
auth: [
398-
{
399-
secretRef: 'render-request-queue-connection-string'
400-
triggerParameter: 'connection'
401-
}
402-
]
403410
}
404-
}
405-
]
406-
407-
scaleMaxReplicas: 5
408-
scaleMinReplicas: 0
409411
```
412+
410413
### Containerize service deployment
411414
:::row:::
412415
:::column:::

0 commit comments

Comments
 (0)