Autoscale vmss instance in azure application gateway on the basis of increasing concurrent session.

Brass Contributor

Hi Team,

 

Please suggest or provide the configuration steps ,How we can configure to autoscale vmss instance behind the azure application gateway on the basis of increasing concurrent session.When number of user increase concurrently on our website ,a new vm instace spin up and scale down when load decreases.

Thanks.

Irshad

5 Replies

@irshad 

To configure autoscaling of VMSS instances based on increasing concurrent sessions behind Azure Application Gateway, you can follow these steps:

  1. Create a VMSS with a minimum and maximum number of instances that you want to scale between. Ensure that the VMSS is configured with the appropriate size and image that you require.
  2. Configure the autoscale settings for the VMSS. In the Azure portal, navigate to the VMSS and select "Autoscale" from the left-hand menu. Create a new autoscale setting with a scaling rule based on the number of concurrent sessions. For example, you can set a rule to increase the number of instances when the number of concurrent sessions exceeds a certain threshold, and to decrease the number of instances when the number of concurrent sessions falls below a certain threshold.
  3. Configure the Azure Application Gateway to use the VMSS as its backend pool. In the Azure portal, navigate to the Application Gateway and select "Backend pools" from the left-hand menu. Add the VMSS as a backend pool and specify the appropriate health probe and port settings.
  4. Configure the Azure Application Gateway to use the autoscale settings for the VMSS. In the Azure portal, navigate to the Application Gateway and select "Autoscaling" from the left-hand menu. Choose the VMSS autoscale setting that you created earlier.

Once you have completed these steps, the VMSS will automatically scale up and down based on the number of concurrent sessions being served by the Azure Application Gateway. This will help to ensure that your website remains responsive and available even during periods of high traffic.

Please mark this thread as closed if this helps :)



Reference only: https://learn.microsoft.com/en-us/azure/architecture/best-practices/auto-scaling

@irshad
To configure autoscaling for a Virtual Machine Scale Set (VMSS) behind an Azure Application Gateway based on the number of concurrent sessions, you'll need to follow these steps:

1- Create an Azure Application Gateway:
If you haven't already, create an Azure Application Gateway and configure it to route traffic to
your VMSS. Follow the instructions in the Microsoft documentation for setting up an
Application Gateway with VMSS: https://docs.microsoft.com/en-us/azure/application-
gateway/configure-autoscaling-vmss
2- Create a custom metric for concurrent sessions:
Unfortunately, Azure Monitor does not provide a built-in metric to monitor concurrent
sessions directly. Instead, you can use the Application Gateway's "Active Connections" metric
as a proxy for concurrent sessions. Alternatively, you can use a custom metric from your
application to monitor concurrent sessions. To do this, you will need to configure your
application to send custom metrics to Azure Monitor using the Application Insights SDK or
another supported method: https://docs.microsoft.com/en-us/azure/azure-
monitor/app/create-new-resource
3- Create an autoscale setting for your VMSS based on the custom metric:
Once you have a custom metric or you're using the "Active Connections" metric, you can
create an autoscale setting for your VMSS based on that metric. Follow these steps to
configure autoscaling based on a custom metric:
a. In the Azure Portal, navigate to your VMSS resource.
b. Click on "Scaling" under the "Settings" section.
c. Click on "Add a rule" and configure the scale-out rule:
- Select your custom metric or "Active Connections" from the "Metric" dropdown.
- Set the "Aggregation type" to "Average" or another appropriate option.
- Configure the "Operator" and "Threshold" according to your requirements, e.g., Operator:
Greater than, Threshold: 100 (for 100 concurrent sessions).
- Set "Duration" to the desired time window for the metric evaluation.
- Set "Action" to "Increase count by" and choose the number of instances to add when
scaling out.
d. Configure a scale-in rule similarly, with an appropriate threshold and "Decrease count by"
action.
e. Save the rules and set the "Cooldown" period to the desired value.

With these configurations in place, your VMSS will automatically scale out when the concurrent sessions (or active connections) increase beyond the defined threshold and scale in when the load decreases.
Thank you for reply.Let me try the setup you suggested.