|
| 1 | +--- |
| 2 | +title: Quickstart - Set up autoscale for applications in Azure Spring Apps Standard consumption plan |
| 3 | +description: Learn how to set up autoscale for applications in Azure Spring Apps Standard consumption plan. |
| 4 | +author: karlerickson |
| 5 | +ms.author: haojianzhong |
| 6 | +ms.service: spring-apps |
| 7 | +ms.topic: quickstart |
| 8 | +ms.date: 03/21/2023 |
| 9 | +ms.custom: devx-track-java |
| 10 | +--- |
| 11 | + |
| 12 | +# Quickstart: Set up autoscale for applications in Azure Spring Apps Standard consumption plan |
| 13 | + |
| 14 | +This article describes how to set up autoscale rules for your applications in Azure Spring Apps Standard consumption plan. The plan uses an Azure Container Apps environment to host your Spring applications, and provides the following management and support: |
| 15 | + |
| 16 | +- Manages automatic horizontal scaling through a set of declarative scaling rules. |
| 17 | +- Supports all the scaling rules that Azure Container Apps supports. |
| 18 | + |
| 19 | +For more information, see [Azure Container Apps documentation](../container-apps/index.yml). |
| 20 | + |
| 21 | +## Prerequisites |
| 22 | + |
| 23 | +- An Azure subscription. If you don't have an Azure subscription, see [Azure free account](https://azure.microsoft.com/free/?WT.mc_id=A261C142F) before you begin. |
| 24 | +- A deployed Azure Spring Apps service instance. |
| 25 | +- At least one application already created in your service instance. |
| 26 | + |
| 27 | +## Scale definition |
| 28 | + |
| 29 | +Scaling is defined by the combination of limits and rules. |
| 30 | + |
| 31 | +- Limits are the minimum and maximum number of instances that your Spring allows. |
| 32 | + |
| 33 | + | Scale limit | Default value | Min value | Max value | |
| 34 | + |--------------------------------------------|---------------|-----------|-----------| |
| 35 | + | Minimum number of instances per deployment | 1 | 0 | 30 | |
| 36 | + | Maximum number of instances per deployment | 10 | 1 | 30 | |
| 37 | + |
| 38 | + By default, the minimum instance count of your Spring application is set to 1 to ensure that your deployment is always running. If you want to scale in to zero, you can set the minimum instance count to zero. |
| 39 | + |
| 40 | +- Rules are the criteria that the autoscaling abides by to add or remove instances. The scale rules include HTTP, TCP, and Custom rules as described in the [Scale rules](../container-apps/scale-app.md#scale-rules) section of [Set scaling rules in Azure Container Apps](../container-apps/scale-app.md). |
| 41 | + |
| 42 | + If you define more than one scale rule, the autoscaling begins when the first condition of any rule is met. |
| 43 | + |
| 44 | +- The *polling interval* and *cooldown period* are two time spans that occur during autoscaling. |
| 45 | + - The polling interval defines the time span between each polling action of real time data as defined by your rules. The polling interval is set to 30 seconds by default. |
| 46 | + - The cooldown period applies only when scaling to zero - for example, to wait five minutes after the last time autoscaling checked the message queue and it was empty. |
| 47 | + |
| 48 | +## Set up autoscale settings |
| 49 | + |
| 50 | +You can set up autoscale settings for your application by using the Azure portal or Azure CLI. |
| 51 | + |
| 52 | +### [Azure portal](#tab/azure-portal) |
| 53 | + |
| 54 | +Use the following steps to define autoscale settings and rules. |
| 55 | + |
| 56 | +1. Sign in to the Azure portal. |
| 57 | +1. Select **Azure Spring Apps** under **Azure services**. |
| 58 | +1. In the **Name** column, select the Azure Spring Apps instance that you want to autoscale. |
| 59 | +1. On the overview page for your Azure Spring Apps instance, select **Apps** in the navigation pane. |
| 60 | +1. Select the application that you want to autoscale. |
| 61 | +1. On the overview page for the selected app, select **Scale out** in the navigation pane. |
| 62 | +1. On the **Scale out (Preview)** page, select the deployment you want to autoscale. |
| 63 | +1. Set up the instance limits of your deployment. |
| 64 | +1. Select **Add** to add your scale rules. To define your custom rules, see [Keda scalers](https://keda.sh/docs/2.9/scalers/). |
| 65 | + |
| 66 | +:::image type="content" source="media/quickstart-apps-autoscale/autoscale-setting.png" alt-text="Screenshot of the Azure portal preview version showing the Scale out page for an app in an Azure Spring Apps instance." lightbox="media/quickstart-apps-autoscale/autoscale-setting.png"::: |
| 67 | + |
| 68 | +### [Azure CLI](#tab/azure-cli) |
| 69 | + |
| 70 | +Use the following commands to create an application in Azure Spring Apps with an autoscaling rule. The replicas count is adjusted automatically according to the count of messages in Azure Service Bus Queue. |
| 71 | + |
| 72 | +```azurecli-interactive |
| 73 | +az spring app create \ |
| 74 | + --resource-group <resource-group-name> \ |
| 75 | + --service <Azure-Spring-Apps-service-instance-name> \ |
| 76 | + --name <app-name> \ |
| 77 | + --secrets "connection-string-secret=<service-bus-connection-string>" \ |
| 78 | + --scale-rule-name azure-servicebus-queue-rule \ |
| 79 | + --scale-rule-type azure-servicebus \ |
| 80 | + --scale-rule-metadata "queueName=my-queue" \ |
| 81 | + "namespace=service-bus-namespace" \ |
| 82 | + "messageCount=5" \ |
| 83 | + --scale-rule-auth "connection=connection-string-secret" \ |
| 84 | + --min-replicas 0 \ |
| 85 | + --max-replicas 5 |
| 86 | +``` |
| 87 | + |
| 88 | +--- |
| 89 | + |
| 90 | +## Clean up resources |
| 91 | + |
| 92 | +Be sure to delete the resources you created in this article when you no longer need them. To delete the resources, just delete the resource group that contains them. You can delete the resource group using the Azure portal. Alternately, to delete the resource group by using Azure CLI, use the following commands: |
| 93 | + |
| 94 | +```azurecli |
| 95 | +echo "Enter the Resource Group name:" && |
| 96 | +read resourceGroupName && |
| 97 | +az group delete --name $resourceGroupName && |
| 98 | +echo "Press [ENTER] to continue ..." |
| 99 | +``` |
| 100 | + |
| 101 | +## Next steps |
| 102 | + |
| 103 | +- [Azure Spring Apps documentation](./index.yml) |
0 commit comments