MSDN Documentation

Your comprehensive guide to Microsoft App Services

Monitoring and Scaling App Services

Effectively monitoring and scaling your Azure App Services is crucial for ensuring optimal performance, availability, and cost-effectiveness. This section covers the key tools and strategies for managing your app's lifecycle.

Monitoring Your App Service

Azure App Services provides a robust set of tools for monitoring the health and performance of your applications:

Key Metrics to Monitor

Focus on these critical metrics to understand your app's performance:

Pro Tip: Configure alerts in Azure Monitor for critical metrics (e.g., CPU > 80%, Memory > 90%, HTTP 5xx errors > 5 in 1 minute) to be notified of potential issues proactively.

Scaling Your App Service

Scaling allows you to adjust the resources allocated to your App Service to meet demand. App Services supports two main types of scaling:

Scale Up (Vertical Scaling)

Scale up involves increasing the resources (CPU, memory, disk space) of your existing App Service instance by moving to a higher pricing tier. This is suitable when your application is resource-bound and cannot be easily distributed across multiple instances.

How to Scale Up:

  1. Navigate to your App Service in the Azure portal.
  2. Under "Scale out (App Service plan)", select "Scale up (App Service plan)".
  3. Choose a new pricing tier and click "Apply".

Scale Out (Horizontal Scaling)

Scale out involves increasing the number of instances running your application. This is ideal for applications that can handle concurrent requests effectively. You can scale out manually or automatically based on predefined rules.

Manual Scale Out

You can manually set the number of instances for your App Service plan.

  1. Navigate to your App Service in the Azure portal.
  2. Under "Scale out (App Service plan)", select "Scale out".
  3. Choose "Scale to a specific number of instances" and enter the desired count.
  4. Click "Apply".
Automatic Scale Out (Autoscaling)

Autoscaling allows your App Service to automatically adjust the number of instances based on performance metrics or a schedule. This ensures your application can handle fluctuating traffic while optimizing costs.

Configure Autoscaling Rules:

  1. Navigate to your App Service in the Azure portal.
  2. Under "Scale out (App Service plan)", select "Autoscale".
  3. Create a new autoscale setting.
  4. Define default rules (e.g., scale out if CPU > 70% for 10 minutes, scale in if CPU < 20% for 15 minutes).
  5. Set the minimum and maximum number of instances.
  6. Configure schedule-based scaling if needed (e.g., increase instances during business hours).
  7. Click "Save".

Example of an autoscaling rule using Azure CLI:

az monitor autoscale create \
    --resource-group myResourceGroup \
    --resource "my-app-service-plan" \
    --min-replicas 1 \
    --max-replicas 10 \
    --capacity 1 \
    --rule "name=ScaleOutCpu;metric=CpuPercentage;operator=GreaterThan;threshold=70;time-aggregation=Average;time-grain=PT1M;min-Downtime=PT10M" \
    --rule "name=ScaleInCpu;metric=CpuPercentage;operator=LessThan;threshold=20;time-aggregation=Average;time-grain=PT1M;min-Downtime=PT15M"

Best Practices