> For the complete documentation index, see [llms.txt](https://docs.scepman.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.scepman.com/azure-configuration/azure-sizing/autoscaling.md).

# Autoscaling

Autoscaling automatically adjusts the number of running instances based on demand to maintain performance and control costs.

## Instructions

{% stepper %}
{% step %}

### Navigate to your App Service Plan's Autoscale Settings

Azure Portal > App Service Plans > *Your SCEPman App Service Plan* > Settings > Scale out

<figure><img src="https://2535731700-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LoGejQeUQcw7lqnQ3WX%2Fuploads%2FJxsXNbiOIkZpTqFHt18U%2Fimage.png?alt=media&amp;token=6a02f149-60fd-4d00-a0c6-3dd4129a9e8d" alt=""><figcaption></figcaption></figure>

{% hint style="warning" %}
Please ensure that your App Service plan uses at least the **S1 or P0V3** pricing tier. Lower tiered plans may not provide multiple instances.
{% endhint %}
{% endstep %}

{% step %}

### Select Rules Based Autoscaling

Select **Rules Based**, then **Configure** to proceed.

<figure><img src="https://2535731700-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LoGejQeUQcw7lqnQ3WX%2Fuploads%2F9rNIdUu3i5QNB5GR3RlB%2Fimage.png?alt=media&amp;token=1eecf795-dbb5-4321-ba5b-0d23e181fb9e" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}

### Configure Autoscale Settings

To scale the instance count based on the current load of the service there must be two scaling rule conditions added. One rule to increase the instance count on heavy load and one rule to decrease the instance count after the load is reduced again.

<figure><img src="https://2535731700-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LoGejQeUQcw7lqnQ3WX%2Fuploads%2FrAJsrjbM9PHu1Teqi8r6%2Fimage.png?alt=media&amp;token=58d2ebf4-8109-4eff-baab-ab4eac80c922" alt=""><figcaption></figcaption></figure>

1. Select **Custom autoscale**
2. Type in an appropriate name in **Autoscale setting name**
3. Select **Scale based on a metric** to enable autoscaling based on a defined rule set
4. Set the instance limits in line with your business requirements:
   * Minimum
   * Maximum
   * Default
5. Select **Add a rule** once you're ready to configure your Autoscaling rules
   {% endstep %}

{% step %}

### Configure Autoscaling Rules

{% hint style="info" %}
We recommend the following settings of the increase and decrease rules.\
But please keep in mind that this can depend on your workload and needs to be monitored and optimized!
{% endhint %}

#### Increase Instance Count Rule

1. **Enable metric divided by instance count**
2. Choose **Greater than** as the Operator and set the threshold to **70** (percent)
3. Set the duration to **10** (minutes)
4. Ensure that the **Time grain statistic** is set to **Average**
5. Ensure that the **Operation** is set to **Increase count by**
6. Set the **Cool down (minutes)** to **15** (minutes)
7. Check the **Instance count (1)** that will be added to the current instances
8. Click **Add** when done

<figure><img src="https://2535731700-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LoGejQeUQcw7lqnQ3WX%2Fuploads%2F6ubxm4jj1jySwLCOVglz%2Fimage.png?alt=media&amp;token=f3b49f46-4ecf-4970-9c4f-0f37709c57b1" alt=""><figcaption></figcaption></figure>

#### Decrease Instance Count Rule

1. Select **Add a rule** to add an additional rule
2. **Enable metric divided by instance count**
3. Choose **Less than** as the Operator and set the threshold to **35** (percent)
4. Set the duration to **20** (minutes)
5. Ensure that the **Time grain statistic** is set to **Average**
6. Ensure that the **Operation** is set to **Decrease count by**
7. Set the **Cool down (minutes)** to **30** (minutes)
8. Check the **Instance count (1)** that will be removed from the current instances
9. Click **Add** when done

<figure><img src="https://2535731700-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LoGejQeUQcw7lqnQ3WX%2Fuploads%2FFR2zvv6GfB3I1bC999qo%2Fimage.png?alt=media&amp;token=f9a0d789-b60d-4595-a26c-8aeeb9391221" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}

### Save Autoscale Settings

Congratulations! Your App Service Plan will now scale up and down in accordance with your rules.

<figure><img src="https://2535731700-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LoGejQeUQcw7lqnQ3WX%2Fuploads%2FzO8pPVQvkJwUTrsxKZfr%2Fimage.png?alt=media&amp;token=0334ffe6-42ee-4746-b12f-26724e204f95" alt=""><figcaption></figcaption></figure>
{% endstep %}
{% endstepper %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.scepman.com/azure-configuration/azure-sizing/autoscaling.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
