How to Configure Network Load Balancing Affinity in Windows Server 2022
Posted on 21st June 2023
Windows Server 2022 includes support for a new feature called Network Load Balancing Affinity. This feature allows you to configure how network load balancing behaves when multiple instances of Windows Server are running on the same physical server.
In this article, we’ll take a look at how to configure Network Load Balancing Affinity in Windows Server 2022. We’ll start by looking at the different types of affinity that are available. We’ll then look at how to configure affinity using the Windows Server 2022 Management Console.
Types of Affinity
There are two types of affinity that can be configured in Windows Server 2022:
Source IP Affinity: This type of affinity causes network load balancing to send traffic from the same source IP address to the same server instance.
Destination IP Affinity: This type of affinity causes network load balancing to send traffic to the same destination IP address to the same server instance.
How to Configure Affinity
Affinity can be configured using the Windows Server 2022 Management Console. To do this, open the Management Console and navigate to the Network Load Balancing section.
In the Network Load Balancing section, select the affinity that you want to configure. In this example, we’ll be configuring source IP affinity.
Once you have selected the affinity that you want to configure, click on the “Edit” button.
In the Edit Affinity window, select the “Enabled” option and then click on the “OK” button.
Your affinity configuration is now complete.
Conclusion
In this article, we’ve looked at how to configure Network Load Balancing Affinity in Windows Server 2022. We’ve started by looking at the different types of affinity that are available. We’ve then looked at how to configure affinity using the Windows Server 2022 Management Console.
Network Load Balancing affinity is a setting that controls how often a client’s requests are directed to the same server in a server cluster. By default, Network Load Balancing (NLB) directs each new request from a client to the server with the lowest load, without regard to which server handled the previous request from that client.
If you enable affinity, NLB directs all requests from the same client IP address to the same server, as long as that server is available and has sufficient capacity to handle the request. If the server becomes unavailable or its load exceeds a configurable threshold, NLB automatically directs requests to another server.
When to Use Affinity
Affinity can be useful in the following scenarios:
You are using session state persistence (also known as “sticky sessions”) in your application, and you want to ensure that all requests from the same client are handled by the same server.
You want to minimize the number of times that a client must authenticate to the server.
You are using an application that stores client data locally on the server (for example, in a database or file system), and you want to minimize the number of times that the client must download that data.
You are using an application that uses client IP addresses for security or billing purposes, and you want to ensure that all requests from the same client are handled by the same server.
You should not enable affinity if your application does not work correctly when client requests are directed to different servers in the cluster. For example, if your application uses in-memory caching of data, and the data is not replicated across servers, enabling affinity might cause some clients to receive outdated data.
How to Configure Affinity
In the Network Load Balancing Manager console, right-click the cluster, and then click Properties.
On the Affinity tab, select the type of affinity that you want to use:
Single: Directs all requests from the same client IP address to the same server. This is the default setting.
Directs all requests from the same client IP address to the same server. This is the default setting. Class C: Directs all requests from clients in the same Class C subnet to the same server.
Directs all requests from clients in the same Class C subnet to the same server. None: Load balances all requests without regard to the source IP address. This is the recommended setting for most applications.
If you are using single affinity, you can also select the option to allow multiple connections from the same client IP address. This option is useful for applications that open multiple connections, such as TCP-based applications.
If you are using single or Class C affinity, you can optionally configure a session persistence timeout. This timeout controls how long NLB will continue to direct requests from the same client to the same server, even if the client’s IP address changes. The timeout is specified in minutes, and the default value is 15 minutes.
You can also configure affinity at the port rule level. For more information, see Configure Affinity for a Port Rule.
When you have finished configuring affinity, click OK.
Network Load Balancing (NLB) affinity allows you to configure how network traffic is distributed among the nodes in an NLB cluster. By default, NLB uses a round-robin approach to distributing traffic, but you can configure affinity to ensure that traffic destined for a particular IP address or port is always routed to the same node in the cluster. There are two types of affinity that you can configure:
- Single – With single affinity, traffic destined for a particular IP address or port is always routed to the same node in the cluster. This can be useful if you have applications that require session persistence (maintaining state between requests) or if you want to ensure that traffic destined for a particular service is always handled by the same server.
- Multiple – With multiple affinity, traffic destined for a particular IP address or port is always routed to the same node in the cluster until that node becomes unavailable. At that point, traffic is routed to another node in the cluster. This can be useful if you have applications that can tolerate some level of downtime or if you want to ensure that traffic is evenly distributed among the nodes in the cluster.
In this article, we’ll show you how to configure single and multiple affinity in Windows Server 2022.
Configuring Single Affinity
To configure single affinity, open the NLB Manager console and select the cluster you want to configure. In the Actions pane, click Edit Properties.
On the General tab, select the Single option under Affinity. You can then specify the IP address or port that you want to configure affinity for.
Click OK to save your changes.
Configuring Multiple Affinity
To configure multiple affinity, open the NLB Manager console and select the cluster you want to configure. In the Actions pane, click Edit Properties.
On the General tab, select the Multiple option under Affinity. You can then specify the IP address or port that you want to configure affinity for.
Click OK to save your changes.
Conclusion
In this article, we’ve shown you how to configure single and multiple affinity in Windows Server 2022. Affinity can be a useful tool for ensuring that traffic is routed appropriately in an NLB cluster.