Skip to content

Commit 7562869

Browse files
Merge pull request #278386 from sipastak/avd-load-balancing-new
Reformat host pool load balancing
2 parents 2c6b041 + 74d0306 commit 7562869

File tree

6 files changed

+124
-97
lines changed

6 files changed

+124
-97
lines changed

.openpublishing.redirection.virtual-desktop.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,11 @@
424424
"source_path_from_root": "/articles/virtual-desktop/fslogix-containers-azure-files.md",
425425
"redirect_url": "/azure/virtual-desktop/fslogix-profile-containers",
426426
"redirect_document_id": true
427+
},
428+
{
429+
"source_path_from_root": "/articles/virtual-desktop/host-pool-load-balancing.md",
430+
"redirect_url": "/azure/virtual-desktop/configure-host-pool-load-balancing",
431+
"redirect_document_id": false
427432
}
428433
]
429434
}

articles/virtual-desktop/TOC.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,6 @@
125125
href: organization-internal-external-commercial-purposes-recommendations.md
126126
- name: Azure Virtual Desktop Agent
127127
href: agent-overview.md
128-
- name: Host pool load balancing methods
129-
href: host-pool-load-balancing.md
130-
displayName: load-balancing, lb
131128
- name: User profile management
132129
items:
133130
- name: FSLogix profile container

articles/virtual-desktop/configure-host-pool-load-balancing.md

Lines changed: 117 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -3,82 +3,156 @@ title: Configure Azure Virtual Desktop load-balancing - Azure
33
description: How to configure the load-balancing method for an Azure Virtual Desktop environment.
44
author: Heidilohr
55
ms.topic: how-to
6-
ms.date: 10/12/2020
6+
ms.date: 06/11/2024
77
ms.author: helohr
88
ms.custom: devx-track-azurepowershell
99
---
10-
# Configure the Azure Virtual Desktop load-balancing method
1110

12-
Configuring the load-balancing method for a host pool allows you to adjust the Azure Virtual Desktop environment to better suit your needs.
11+
# Host pool load balancing algorithms in Azure Virtual Desktop
1312

14-
>[!NOTE]
15-
> This does not apply to a persistent desktop host pool because users always have a 1:1 mapping to a session host within the host pool.
13+
Azure Virtual Desktop supports two load balancing algorithms for pooled host pools. Each algorithm determines which session host is used when a user starts a remote session. Load balancing doesn't apply to personal host pools because users always have a 1:1 mapping to a session host within the host pool.
1614

17-
## Prerequisites
15+
The following load balancing algorithms are available for pooled host pools:
1816

19-
This article assumes you've followed the instructions in [Set up the Azure Virtual Desktop PowerShell module](powershell-module.md) to download and install the PowerShell module and sign in to your Azure account.
17+
- **Breadth-first**, which aims to evenly distribute new user sessions across the session hosts in a host pool. You don't have to specify a maximum session limit for the number of sessions.
2018

21-
## Configure breadth-first load balancing
19+
- **Depth-first**, which keeps starting new user sessions on one session host until the maximum session limit is reached. Once the session limit is reached, any new user connections are directed to the next session host in the host pool until it reaches its session limit, and so on.
2220

23-
Breadth-first load balancing is the default configuration for new non-persistent host pools. Breadth-first load balancing distributes new user sessions across all available session hosts in the host pool. When configuring breadth-first load balancing, you may set a maximum session limit per session host in the host pool.
21+
You can only configure one of the load balancing at a time per pooled host pool, but you can change which one is used after a host pool is created. However, both load balancing algorithms share the following behaviors:
2422

25-
To configure a host pool to perform breadth-first load balancing without adjusting the maximum session limit, run the following PowerShell cmdlet:
23+
- If a user already has an active or disconnected session in the host pool and signs in again, the load balancer will successfully redirect them to the session host with their existing session. This behavior applies even if [drain mode](drain-mode.md) has been enabled for that session host.
2624

27-
```powershell
28-
Update-AzWvdHostPool -ResourceGroupName <resourcegroupname> -Name <hostpoolname> -LoadBalancerType 'BreadthFirst'
29-
```
25+
- If a user doesn't already have a session on a session host in the host pool, the load balancer doesn't consider a session host where drain mode has been enabled.
3026

31-
After that, to make sure you've set the breadth-first load balancing method, run the following cmdlet:
27+
- If you lower the maximum session limit on a session host while it has active user sessions, the change doesn't affect existing user sessions.
3228

33-
```powershell
34-
Get-AzWvdHostPool -ResourceGroupName <resourcegroupname> -Name <hostpoolname> | format-list Name, LoadBalancerType
29+
## Breadth-first load balancing algorithm
3530

36-
Name : hostpoolname
37-
LoadBalancerType : BreadthFirst
38-
```
31+
The breadth-first load balancing algorithm aims to distribute user sessions across session hosts to optimize for session performance. Breadth-first is ideal for organizations that want to provide the best experience for users connecting to their remote resources as session host resources, such as CPU, memory, and disk, are generally less contended.
3932

40-
To configure a host pool to perform breadth-first load balancing and to use a new maximum session limit, run the following PowerShell cmdlet:
33+
The breadth-first algorithm first queries session hosts in a host pool that allow new connections. The algorithm then selects a session host randomly from half the set of available session hosts with the fewest sessions. For example, if there are nine session hosts with 11, 12, 13, 14, 15, 16, 17, 18, and 19 sessions, a new session doesn't automatically go to the session host with the fewest sessions. Instead, it can go to any of the first five session hosts with the fewest sessions at random. Due to the randomization, some sessions may not be evenly distributed across all session hosts.
4134

42-
```powershell
43-
Update-AzWvdHostPool -ResourceGroupName <resourcegroupname> -Name <hostpoolname> -LoadBalancerType 'BreadthFirst' -MaxSessionLimit ###
44-
```
35+
## Depth-first load balancing algorithm
4536

46-
## Configure depth-first load balancing
37+
The depth-first load balancing algorithm aims to saturate one session host at a time. This algorithm is ideal for cost-conscious organizations that want more granular control on the number of session hosts available in a host pool, enabling you to more easily scale down when there are fewer users.
4738

48-
Depth-first load balancing distributes new user sessions to an available session host with the highest number of connections but has not reached its maximum session limit threshold.
39+
The depth-first algorithm first queries session hosts that allow new connections and haven't reached their maximum session limit. The algorithm then selects the session host with most sessions. If there's a tie, the algorithm selects the first session host from the query.
4940

50-
>[!IMPORTANT]
51-
>When configuring depth-first load balancing, you must set a maximum session limit per session host in the host pool.
41+
You must [set a maximum session limit](configure-host-pool-load-balancing.md#configure-load-balancing) when using the depth-first algorithm. You can use Azure Virtual Desktop Insights to monitor [the number of sessions on each session host](insights-use-cases.md#session-host-utilization) and [session host performance](insights-use-cases.md#session-host-performance) to help determine the best maximum session limit for your environment.
5242

53-
To configure a host pool to perform depth-first load balancing, run the following PowerShell cmdlet:
43+
> [!IMPORTANT]
44+
> Once all session hosts have reached the maximum session limit, you need to increase the limit or [add more session hosts to the host pool](add-session-hosts-host-pool.md).
5445
55-
```powershell
56-
Update-AzWvdHostPool -ResourceGroupName <resourcegroupname> -Name <hostpoolname> -LoadBalancerType 'DepthFirst' -MaxSessionLimit ###
57-
```
5846

59-
>[!NOTE]
60-
> The depth-first load balancing algorithm distributes sessions to session hosts based on the maximum session host limit (`-MaxSessionLimit`). This parameter's default value is `999999`, which is also the highest possible number you can set this variable to. This parameter is required when you use the depth-first load balancing algorithm. For the best possible user experience, make sure to change the maximum session host limit parameter to a number that best suits your environment.
47+
## Prerequisites
6148

62-
To make sure the setting has updated, run this cmdlet:
49+
To configure load balancing for a pooled host pool, you need:
6350

64-
```powershell
65-
Get-AzWvdHostPool -ResourceGroupName <resourcegroupname> -Name <hostpoolname> | format-list Name, LoadBalancerType, MaxSessionLimit
51+
- An existing pooled host pool.
52+
53+
- An Azure account assigned the [Desktop Virtualization Host Pool Contributor](rbac.md#desktop-virtualization-host-pool-contributor) role.
54+
55+
- If you want to use Azure PowerShell locally, see [Use Azure CLI and Azure PowerShell with Azure Virtual Desktop](cli-powershell.md) to make sure you have the [Az.DesktopVirtualization](/powershell/module/az.desktopvirtualization) PowerShell module installed. Alternatively, use the [Azure Cloud Shell](../cloud-shell/overview.md).
6656

67-
Name : hostpoolname
68-
LoadBalancerType : DepthFirst
69-
MaxSessionLimit : 6
70-
```
7157

72-
## Configure load balancing with the Azure portal
58+
## Configure load balancing
7359

74-
You can also configure load balancing with the Azure portal.
60+
### [Azure portal](#tab/portal)
7561

76-
To configure load balancing:
62+
To configure load balancing with the Azure portal:
7763

7864
1. Sign in to the [Azure portal](https://portal.azure.com).
65+
7966
2. Search for and select **Azure Virtual Desktop** under Services.
67+
8068
3. In the Azure Virtual Desktop page, select **Host pools**.
69+
8170
4. Select the name of the host pool you want to edit.
71+
8272
5. Select **Properties**.
73+
8374
6. Enter the **Max session limit** into the field and select the **load balancing algorithm** you want for this host pool in the drop-down menu.
75+
8476
7. Select **Save**. This applies the new load balancing settings.
77+
78+
79+
### [Azure PowerShell](#tab/powershell)
80+
81+
Here's how to configure load balancing with Azure PowerShell.
82+
83+
[!INCLUDE [include-cloud-shell-local-powershell](includes/include-cloud-shell-local-powershell.md)]
84+
85+
2. Configure a host pool to perform breadth-first or depth-first load balancing using the Update-AzWvdHostPool cmdlet. Here are some examples:
86+
87+
- To set breadth-first without adjusting the maximum session limit, run the following command:
88+
89+
```powershell
90+
Update-AzWvdHostPool -ResourceGroupName <resourcegroupname> -Name <hostpoolname> -LoadBalancerType 'BreadthFirst'
91+
```
92+
93+
- To set depth-first and adjust the maximum session limit to 10, run the following command:
94+
95+
```powershell
96+
Update-AzWvdHostPool -ResourceGroupName <resourcegroupname> -Name <hostpoolname> -LoadBalancerType 'DepthFirst' -MaxSessionLimit 10
97+
```
98+
99+
3. To make sure the setting has updated, run this cmdlet:
100+
101+
```powershell
102+
Get-AzWvdHostPool -ResourceGroupName <resourcegroupname> -Name <hostpoolname> | format-list Name, LoadBalancerType, MaxSessionLimit
103+
```
104+
105+
```Output
106+
Name : hostpoolname
107+
LoadBalancerType : DepthFirst
108+
MaxSessionLimit : 6
109+
```
110+
111+
112+
### [Azure CLI](#tab/cli)
113+
114+
Here's how to configure load balancing with Azure CLI.
115+
116+
[!INCLUDE [include-cloud-shell-local-cli](includes/include-cloud-shell-local-cli.md)]
117+
118+
2. Configure a host pool to perform breadth-first or depth-first load balancing. Here are some examples:
119+
120+
- To set breadth-first without adjusting the maximum session limit, run the following command:
121+
122+
```azurecli
123+
az desktopvirtualization hostpool update \
124+
--resource-group $resourceGroupName \
125+
--name $hostPoolName \
126+
--load-balancer-type BreadthFirst
127+
```
128+
129+
- To set depth-first and adjust the maximum session limit to 10, run the following command:
130+
131+
```azurecli
132+
az desktopvirtualization hostpool update \
133+
--resource-group $resourceGroupName \
134+
--name $hostPoolName \
135+
--load-balancer-type DepthFirst \
136+
--max-session-limit 10
137+
```
138+
139+
4. To make sure the setting has updated, run this cmdlet:
140+
141+
```azurecli
142+
az desktopvirtualization hostpool show
143+
--resource-group $resourceGroupName
144+
--name $hostPoolName
145+
```
146+
147+
---
148+
149+
>[!IMPORTANT]
150+
>When configuring depth-first load balancing, you must set a maximum session limit per session host in the host pool.
151+
152+
>[!NOTE]
153+
> The depth-first load balancing algorithm distributes sessions to session hosts based on the maximum session host limit (`-MaxSessionLimit`). When you set breadth-first, the parameter's default value is `999999`, which is also the highest possible number you can set this variable to. For the best possible user experience, make sure to change the maximum session host limit parameter to a number that best suits your environment.
154+
155+
156+
## Next steps
157+
158+
- Understand how [autoscale](autoscale-scenarios.md) can automatically scale the number of available session hosts in a host pool.

articles/virtual-desktop/host-pool-load-balancing.md

Lines changed: 0 additions & 49 deletions
This file was deleted.

articles/virtual-desktop/scaling-automation-logic-apps.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ Peak and off-peak hours are defined as:
3535
During peak usage time, the job checks the current number of sessions and the VM capacity of the current running session host for each host pool. It uses this information to calculate if the running session host VMs can support existing sessions based on the *SessionThresholdPerCPU* parameter defined for the **CreateOrUpdateAzLogicApp.ps1** file. If the session host VMs can't support existing sessions, the job starts extra session host VMs in the host pool.
3636

3737
>[!NOTE]
38-
>*SessionThresholdPerCPU* doesn't restrict the number of sessions on the VM. This parameter only determines when new VMs need to be started to load-balance the connections. To restrict the number of sessions, you need to follow the instructions [Update-AzWvdHostPool](configure-host-pool-load-balancing.md#configure-breadth-first-load-balancing) to configure the *MaxSessionLimit* parameter accordingly.
38+
>*SessionThresholdPerCPU* doesn't restrict the number of sessions on the VM. This parameter only determines when new VMs need to be started to load-balance the connections. To restrict the number of sessions, you need to follow the instructions to [configure the *MaxSessionLimit* parameter](configure-host-pool-load-balancing.md#configure-load-balancing) accordingly.
3939
4040
During the off-peak usage time, the job determines how many session host VMs should be shut down based on the *MinimumNumberOfRDSH* parameter. If you set the *LimitSecondsToForceLogOffUser* parameter to a non-zero positive value, the job will set the session host VMs to drain mode to prevent new sessions from connecting to the hosts. The job will then notify any currently signed in users to save their work, wait the configured amount of time, and then force the users to sign out. Once all user sessions on the session host VM have been signed out, the job will shut down the VM. After the VM shuts down, the job will reset its session host drain mode.
4141

0 commit comments

Comments
 (0)