Can NLB support mulitple target groups in one listener?

0

When building a network load balancer with the cloud formation, I got the following error:

  • you cannot specify multiple target groups in a single action with a load balancer of type 'network' I am adding two target groups in a single default action for a network listener, the part of cloud formation is at the bottom of the page.

If I create a NLB with 2 AZs, how can I add two target groups for 2 AZs into one listener of the NLB? I thought this would make the NLB fault-tolerant, but elastic load balancing doesn't allow this.

I have to work around this by adding targets in 2 AZs into one target group associating with the listener, but this will make load balancing cross the AZs which might cause higher latency and data transfer fees for NLB.

 NLB:
    Type: AWS::ElasticLoadBalancingV2::LoadBalancer
    Properties:
      Name: !Sub "${NetworkStackName}-nlb"
      Scheme: "internet-facing"
      SecurityGroups: 
        - Fn::ImportValue: 
            'Fn::Sub': '${NetworkStackName}-PubSecurityGroupID'
      Subnets:
        - Fn::ImportValue: 
            'Fn::Sub': '${NetworkStackName}-PublicSubnetID-1'
        - Fn::ImportValue: 
            'Fn::Sub': '${NetworkStackName}-PublicSubnetID-2'    
      Tags:
      - Key: Name
        Value: !Sub "${NetworkStackName}-nlb"
      Type: "network"

  NLBListener1:
    Type: AWS::ElasticLoadBalancingV2::Listener
    Properties:
      DefaultActions: 
        - Type: forward
          ForwardConfig:
            TargetGroups: 
              - TargetGroupArn:
                  Fn::ImportValue: 
                    'Fn::Sub': '${NetworkStackName}-nlb-target-group-1'      
        - Type: forward
          ForwardConfig:
            TargetGroups: 
              - TargetGroupArn:
                  Fn::ImportValue: 
                    'Fn::Sub': '${NetworkStackName}-nlb-target-group-2'                                   
      LoadBalancerArn: !Ref NLB
      Port: 80
      Protocol: TCP
feita há um ano1 mil visualizações
1 Resposta
1
Resposta aceita

To achieve what your looking for is to add 2 targets in one target group on your listener and then disable cross zone load balancing.

When cross-zone load balancing is off, each load balancer node distributes traffic across only the registered targets in its Availability Zone.

profile picture
ESPECIALISTA
respondido há um ano
profile picture
ESPECIALISTA
avaliado há 10 meses
  • I might misunderstand the Target Group definition. I thought it was AZ-related but not. It seems a Target Group is just a virtual container including the targets from different AZs. Regarding the NLB, cross-zone load balancing is off by default, so the traffic is always routed to the targets in the same AZ.

    Is this a correct understanding?

  • You are correct with your understanding. A target group isn’t specific per AZ and multi AZ is disabled by default on a network load balancer.

Você não está conectado. Fazer login para postar uma resposta.

Uma boa resposta responde claramente à pergunta, dá feedback construtivo e incentiva o crescimento profissional de quem perguntou.

Diretrizes para responder a perguntas