Runbook
Azure Web App Performance Downtime or Slowness due to High Traffic
Back to Runbooks
Overview
This incident type refers to situations where an Azure web app experiences slow performance or downtime due to increased traffic. When the traffic to a web app increases, it can overload the server, causing it to respond slowly or even crash. This can lead to downtime, which can affect the user experience and impact the business. To resolve this issue, the web app can be scaled vertically (scale up/down) or horizontally (scale out/in) based on traffic patterns. Auto-scaling rules can also be configured to handle traffic fluctuations automatically.
Parameters
1export WEB_APP_NAME="PLACEHOLDER"23export RESOURCE_GROUP_NAME="PLACEHOLDER"45export APP_SERVICE_PLAN_ID="PLACEHOLDER"67export APP_SERVICE_PLAN_NAME="PLACEHOLDER"89export AUTOSCALE_SETTING_NAME="PLACEHOLDER"1011export NEW_INSTANCE_SKU="PLACEHOLDER"1213export MAX_INSTANCES="PLACEHOLDER"1415export MIN_INSTANCES="PLACEHOLDER"
Debug
Check the current status of the web app:
az webapp show --name ${WEB_APP_NAME} --resource-group ${RESOURCE_GROUP_NAME} --query "state"
Check the logs of the web app to identify any errors or performance issues:
az webapp log tail --name ${WEB_APP_NAME} --resource-group ${RESOURCE_GROUP_NAME}
Check the current resource usage of the web app:
az monitor metrics list --resource ${APP_SERVICE_PLAN_ID} --metric "CpuPercentage" "MemoryPercentage" --interval PT1H
Check the current number of instances of the web app:
az appservice plan show --name ${APP_SERVICE_PLAN_NAME} --resource-group ${RESOURCE_GROUP_NAME} --query "sku.capacity"
Check the current auto-scaling rules of the web app:
az monitor autoscale show --name ${AUTOSCALE_SETTING_NAME} --resource-group ${RESOURCE_GROUP_NAME}
Repair
Scale the web app vertically (scale up/down) to increase its capacity. This involves adding more resources such as RAM, CPU, and storage to the server.
1#!/bin/bash2345# Set the App Service Plan name67APP_SERVICE_PLAN_NAME=${APP_SERVICE_PLAN_NAME}891011# Set the Azure resource group name1213RESOURCE_GROUP=${RESOURCE_GROUP_NAME}14151617# Set the new instance size for the web app1819NEW_INSTANCE_SKU=${NEW_INSTANCE_SKU}20212223# Scale the web app vertically2425az appservice plan update --name $APP_SERVICE_PLAN_NAME --resource-group $RESOURCE_GROUP --sku $NEW_INSTANCE_SKU
Scale the web app horizontally
1#!/bin/bash2345# Define variables67RESOURCE_GROUP=${RESOURCE_GROUP_NAME}89PLAN=${APP_SERVICE_PLAN_NAME}1011COUNT=${MAX_INSTANCES}12131415# Scale the web app horizontally1617az appservice plan update --number-of-workers $COUNT --name $APP_SERVICE_PLAN_NAME --resource-group $RESOURCE_GROUP
Configure auto-scaling rules to handle traffic fluctuations automatically. This ensures that the web app can handle increased traffic without manually scaling up or down.
1# Define variables23RESOURCE_GROUP=${RESOURCE_GROUP}45APP_SERVICE_PLAN_ID=${APP_SERVICE_PLAN_ID}67AUTOSCALE_SETTING_NAME=${AUTOSCALE_SETTING_NAME}89MIN_INSTANCES=${MIN_INSTANCES}1011MAX_INSTANCES=${MAX_INSTANCES}12131415# Configure auto-scaling settings1617az monitor autoscale create \1819 --resource-group $RESOURCE_GROUP \2021 --resource-id $APP_SERVICE_PLAN_ID \2223 --name $AUTOSCALE_SETTING_NAME \2425 --min-count $MIN_INSTANCES \2627 --max-count $MAX_INSTANCES \2829 --count 130313233# Create auto-scaling scale out rule3435az monitor autoscale rule create \3637 --resource-group $RESOURCE_GROUP \3839 --autoscale-name $AUTOSCALE_SETTING_NAME \4041 --scale out 1 \4243 --condition "Percentage CPU > 75 avg 5m"44454647# Create auto-scaling scale in rule4849az monitor autoscale rule create \5051 --resource-group $RESOURCE_GROUP \5253 --autoscale-name $AUTOSCALE_SETTING_NAME \5455 --scale in 1 \5657 --condition "Percentage CPU < 25 avg 5m"
Learn more
Related Runbooks
Check out these related runbooks to help you debug and resolve similar issues.