Networking & Content Delivery

Network Load Balancers now support Weighted Target Groups

Introduction

Today Amazon Web Services (AWS) is launching weighted target groups for Network Load Balancers (NLB). This feature allows users to configure static weights among multiple NLB target groups. Weighted target groups enable you to easily perform blue/green or canary deployment strategies with zero downtime and without the need of multiple load balancers. This feature is available now on new and existing NLBs in all commercial Regions, including GovCloud Regions.

Prior to the introduction of this feature, users needed to configure multiple NLBs with separate target groups and manage weights in Route 53. Weighted target groups allow you to reduce infrastructure costs and operational overhead.

Users can assign numeric weights between 0 and 999 to each NLB target group. Traffic will continue to be distributed across all configured Availability Zones but can now be influenced by a weight metric.

Diagram of an NLB and two equal-weighted target groups.

Figure 1: NLB with equal-weight target groups

In the example shown in Figure 1, Target Groups A and B are set to receive an equal share of traffic by configuring an equal weight of 25 on each target group. Target group weights are configurable as integers, with valid values from 0 – 999. If each target group contains three Amazon EC2 instances, then each instance will handle approximately 16.66% of the total load (50% / 3 instances).

Prerequisites

This post assumes you are familiar with NLBs and the component target groups and listeners.

Use Cases

1) Blue/Green Deployment

If you maintain multiple versions of your application in a blue/green deployment, you can now use NLB weighted target groups to steer traffic between them.

Two target groups, one with 100% weight and one with 0% weight

Figure 2: Target group weight detail

To modify the weight of each target group, use the AWS Management Console, NLB ModifyListener API, or the AWS Command Line Interface (AWS CLI).

aws elbv2 modify-listener \
--listener-arn <Listener ARN> \
--protocol TCP \
--port 443 \
--default-actions '[{
    "Type": "forward",
    "ForwardConfig": {
        "TargetGroups": [{
            "TargetGroupArn": "<Target Group Blue ARN>",
            "Weight": 0
        },
        {
            "TargetGroupArn": "<Target Group Green ARN>",
            "Weight": 100
        }]
    }
}]'

The result will shift new traffic from the Blue target group to the Green target group after a short period of up to 3 minutes.

2) Performing Target Group Maintenance

If your application is split into multiple target groups, you can adjust the weights of your target groups to perform maintenance on a portion of your compute instances. In this example, traffic is distributed across three target groups with an equal weight.

Three target groups with equal weights

Figure 3: Equal-weighted target groups

To perform maintenance on the instances in the NLB-WTG-1-IPv6 target group, adjust the weight of that group to zero so that it will not receive new traffic.

After the weight adjustment:

Three target groups with only two configured to split the load with a weight of 33 each, and the 3rd weight adjusted to 0

Figure 4: Traffic shifted from three target groups to two

While the integers of 33 remain the same, the overall total of 66 is now only split between the two groups, resulting in a 50% distribution of traffic. You can verify the traffic flow by inspecting the NewFlowCount Amazon CloudWatch metric with the TargetGroup dimension selected.

A line graph with three lines of roughly equal values over the span of 30 minutes

Figure 5: The CloudWatch NewFlowCount metric displaying data using the TargetGroup dimension

Figure 5 depicts three target groups with equal weights. Over time, the request distribution becomes more evenly balanced across all three target groups.

A line graph with two lines of roughly equal values over the span of one hour

Figure 6: Two target groups share an equal load after removing one target group from service

Figure 6 depicts the result of setting one of the to a zero weight. The requests continue to be balanced between the two remaining active target groups.

Considerations

Listener Types

Each listener that contains weighted target groups must contain target groups that consist of just one protocol. A single listener cannot contain TCP and TLS weighted target groups together. For example, a blue/green deployment with a TLS listener must contain all TLS or all TCP target groups. A “blue” TCP target group cannot be weighted with a “green” TLS target group.

Stickiness

Weighted target groups support stickiness for TCP, UDP and TCP_UDP listeners. The stickiness setting is configured at the listener level under Load Balancer details and applies to all target groups associated with the listener. if a target group weight changes, or a target group is added or removed. By default, stickiness is not enabled.

Mixed IP Address Types

As of the writing of this blog post, an NLB listener must contain weighted target groups with the same internet protocol version, either all IPv4, or all IPv6.

Monitoring

The launch of weighted target groups for these existing NLB CloudWatch metrics: NewFlowCount, NewFlowCount_TCP, NewFlowCount_TLS, NewFlowCount_UDP, ActiveFlowCount, ActiveFlowCount_TCP, ActiveFlowCount_TLS, and ActiveFlowCount_UDP. These existing metrics can now be viewed on a per-target group basis to compare flow counts between target groups. Compare the new and active flow counts of different target groups to determine the effective traffic weights among the target groups.

Weighted Routing Evaluation

Use the weighted routing evaluation feature located in the listener details console page to evaluate target distribution and detailed cross-zone settings. This feature can help identify inconsistencies like unequal numbers of targets in each load balancer zone, which would impact the configured target group weights if cross-zone load balancing is disabled.

The evaluate button is shown in the NLB service console

Figure 7: The weighted routing evaluation feature in the NLB console

In Figure 8, below, I have three target groups with one target in each Availability Zone. Cross-zone load balancing is enabled, so this is still a valid configuration.

The results of the weighted routing evaluation feature showing even target distribution and consistent cross-zone settings

Figure 8: Weighted routing evaluation results

Conclusion

Use weighted target groups to improve flexibility in traffic steering to your NLB target groups. Whether you’re supporting a blue/green deployment, a canary deployment, or distributing traffic in a custom way, create a weighted target group today and try your use case. To get started with weighted target groups, visit the target groups section on the console or check out the weighted target group documentation.