Intermediate Tutorial: Scaling Azure App Service

This tutorial guides you through the process of scaling your Azure App Service to handle varying loads and ensure optimal performance and availability for your web applications.

Understanding Scaling in App Service

Azure App Service offers two primary scaling methods:

Scenario: Handling Increased Traffic

Imagine your web application is experiencing a sudden surge in user traffic due to a successful marketing campaign. To maintain a smooth user experience, you need to scale your App Service.

Steps to Scale Out Your App Service

  1. Navigate to Your App Service

    Log in to the Azure portal and select your App Service from the list of resources.

  2. Access Scale Out Settings

    In the App Service menu blade, under "Settings", select "Scale out (App Service plan)".

  3. Configure Manual Scale Out

    You will see options for "Manual scale" and "Custom rules". For this scenario, we'll use manual scaling.

    • Select "Manual scale".
    • In the "Number of instances" field, set the desired number of instances. For example, if you currently have 2 instances and expect traffic to double, you might set it to 4.
    Azure App Service Manual Scale Out Configuration
    Configuring manual scale out in the Azure portal.
  4. Save Changes

    Click the "Save" button at the top of the blade. Azure will begin provisioning and starting the new instances.

Automatic Scaling with Custom Rules

For dynamic traffic patterns, setting up custom scaling rules is more efficient. This allows App Service to automatically scale out or in based on metrics like CPU usage, memory, or HTTP queue length.

Key Metrics for Auto-Scaling:

  • CPU Percentage: Scale out when CPU usage exceeds a defined threshold.
  • Memory Percentage: Scale out when memory consumption is high.
  • HTTP Queue Length: Scale out when requests are waiting in the queue for processing.

You can also define rules to scale in when the load decreases, saving costs.

Steps to Configure Custom Rules

  1. Navigate to Autoscale Settings

    From the App Service menu, select "Scale out (App Service plan)", then click on "Custom rules".

  2. Create a New Rule

    Click "+ Add a rule" to define a new scaling condition.

    • Metric: Choose a metric (e.g., `CPU Percentage`).
    • Operator: Select the comparison operator (e.g., `GreaterThan`).
    • Threshold: Set the value that triggers the rule (e.g., `75`).
    • Action: Define what happens when the condition is met. For scaling out, choose "Increase count" and specify the number of instances to add.
  3. Define Scale-In Rules

    It's crucial to also define rules for scaling in to reduce costs when traffic subsides. Set up similar rules but with conditions that trigger a decrease in instance count.

  4. Set Instance Limits

    Configure the "Default number of instances", "Minimum number of instances", and "Maximum number of instances" to control the scaling behavior and prevent excessive scaling.

    Azure App Service Autoscaling Rules Configuration
    Configuring custom autoscaling rules.
  5. Save Configuration

    Click "Save" to apply your custom autoscaling rules.

Important Considerations

By implementing effective scaling strategies, you can ensure your Azure App Service remains responsive, available, and cost-efficient, regardless of user demand.

Next, explore monitoring your App Service to gain deeper insights into its performance.