Target Group

In AWS, a Target Group is a crucial component used with Elastic Load Balancers (ELBs) like the Application Load Balancer (ALB) and Network Load Balancer (NLB). The Target Group is responsible for directing traffic to registered targets, typically instances or IP addresses, based on the routing rules configured in the load balancer.

Here are key points to understand about Target Groups:

  1. Grouping Targets:
    • A Target Group groups together a set of targets, which can be Amazon EC2 instances, containers, IP addresses, or Lambda functions.
  2. Routing Decisions:
    • The Load Balancer, such as ALB, uses the rules defined in the Target Group to make routing decisions for incoming traffic.
  3. Target Types: Instance: Targets specified by instance ID. IP: Targets specified by IP addresses, within specific CIDR blocks. Lambda: Use Lambda functions as targets.
  4. Health Checks:
    • Target Groups regularly perform health checks on the registered targets to ensure they are responsive and healthy.
  5. Dynamic Registration:
    • Targets can be dynamically registered or deregistered from a Target Group based on Auto Scaling policies or other dynamic factors.
  6. Multi-Port Target Groups:
    • For Application Load Balancers, a single Target Group can handle traffic on multiple ports, simplifying the configuration.
  7. Path-Based Routing:
    • With Application Load Balancers, Target Groups support path-based routing, allowing different paths in the URL to be directed to different sets of targets.
  8. Host-Based Routing:
    • Application Load Balancers also support host-based routing, allowing routing based on the host header in the HTTP request.
  9. HTTP/HTTPS Health Checks:
    • Target Groups can perform health checks at the HTTP/HTTPS protocol level, ensuring not just network connectivity but also application-level health.
  10. Lambda Function Targets:
    • Target Groups can include AWS Lambda functions as targets, allowing load balancing for serverless applications.
  11. Protocol Support:
    • Target Groups support various protocols, including HTTP, HTTPS, TCP, and Lambda for different use cases.
  12. Integration with Auto Scaling:
    • Target Groups seamlessly integrate with Auto Scaling groups, allowing automatic registration and deregistration of instances based on scaling policies.
  13. Cross-Zone Load Balancing:
    • Target Groups can be configured for cross-zone load balancing, distributing traffic evenly across instances in different Availability Zones.
  14. Registered Targets: Explore how ALBs act as a single point of contact, distributing incoming traffic across healthy registered targets.
  15. Automatic Target Weights (ATW):
    • Anomaly Detection: ATW monitors targets for performance anomalies, adjusting traffic dynamically.
    • Anomaly Mitigation: ATW can automatically route traffic away from anomalous targets, aiding recovery.
  16. Deregistration Delay: - Customize the time ALB waits before completing the deregistration process, helping in-flight requests to complete.
  17. Slow Start Mode: Understand how slow start mode allows targets to warm up before receiving a full share of requests.

In summary, a Target Group is a logical grouping of targets that enables a load balancer to efficiently distribute incoming traffic, perform health checks, and adapt dynamically to changes in the application environment. It is a critical element in creating scalable, highly available, and flexible load balancing configurations in AWS.

Create First Target Group

To create a Target Group in AWS, follow these steps:

  1. Go to the Amazon EC2 console by visiting https://console.aws.amazon.com/ec2/.
  2. In the navigation pane, locate and select "Target Groups" under the "LOAD BALANCING" section.
  3. Click on "Create target group."
  4. Choose the target type based on your requirements:
    • Instances: Register targets by instance ID.
    • IP addresses: Register targets by IP address.
    • Lambda function: Register a Lambda function as a target.
  5. Provide a unique name for the target group in the "Target group name" field. The name should be unique per region per account, contain up to 32 alphanumeric characters or hyphens, and should not start or end with a hyphen.
  6. (Optional) Adjust the default values for "Protocol and Port" if needed.
  7. If the target type is Instances or IP addresses, select either IPv4 or IPv6 as the IP address type. Note that the selected IP address type cannot be changed after the target group is created.
  8. For the VPC field, choose a virtual private cloud (VPC). For IP address target types, select a VPC supporting the chosen IP address type.
  9. (Optional) Modify the default value for "Protocol version" if needed.
  10. (Optional) Customize health check settings in the "Health checks" section. If the target type is a Lambda function, enable health checks if needed.
  11. (Optional) Add tags by expanding the "Tags" section and selecting "Add tag." Enter the tag key and tag value, then choose "Next."
  12. (Optional) Add targets:
    • If the target type is Instances, select instances, enter ports, and choose "Include as pending."
    • If the target type is IP addresses, select a network VPC, enter IP addresses and ports, then choose "Include as pending."
    • If the target type is a Lambda function, specify a single Lambda function or skip this step.
  13. Click on "Create target group."
  14. (Optional) Specify the target group in a listener rule if needed. Refer to "Listener Rules" for more information.