A target group is a configuration container that groups targets and is used to route connection requests to one or more of the registered targets. When created, the listener is defined for incoming connections, and the target group lists the devices or servers to connect to on the backend. Also, the target group contains many different conditions that define how you want the ELB to handle the requests. When the conditions of the target group are met, traffic gets forwarded to the matching target group. Multiple target groups can be defined with each one used for a different type of request.
You will add the target servers that can be a microservice such as a container or a virtual server such as an EC2 instance. Health checks are also applied at the target group level, and the targets must pass a health check to receive connections.
Each target group must have a protocol and port number defined to route traffic to. This is commonly a web-based protocol such as HTTP or HTTPS, and the port numbers are from the complete range of 1 to 65535. If HTTPS is requested, then a digital certificate must be installed on the targets.
When a target group is created, a target type must be defined and cannot be changed after creation.
Target types include the following:
The IP targets are from the private IP address blocks defined in RFCs 1918 and 65598 and include the subnets 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16, and 100.64.0.0/10. You cannot use public routable IP addresses in IP-based targets. By using IP addressing, you can specify servers that are in your private data center if it is routable to the VPC and over either a direct connect or a VPN interconnect.
If you specify Lambda, you will register your Lambda function, and the ELB will invoke the Lambda on a per-connection request basis. The Lambda function and target group must be in the same region. Connection content from the ELB to the Lambda are in JSON format with a maximum response size of 1MB. There is no WebSocket or local zone support.
The IP version needs to be specified in the target group and is usually the IPv4 address type; however, you can also specify IPv6 or both IPv4 and IPv6.
While the default protocol in the target group is HTTP version 1.1, you can specify HTTP/2 or gRPC.
gRPC is supported only by using HTTP where the target types are instance and IP. Lambda is not supported, and health check responses need to be defined and not automatically populated.
HTTP/2 also is supported only with secure HTTPS connections and for the instance types and IP.
The ELB listener is the entry point for clients, and the ELB’s job is to distribute these connections across the registered and healthy targets. A target can belong to more than one target group, which means that a single server can host multiple applications. To scale your operations, multiple additional targets can be added to the group to meet demand; the servers will start receiving traffic as soon as they register and pass the health check. To remove capacity, you need to deregister the targets from the group to remove them. This does not affect the target server; it just takes it out of the group and stops receiving connection requests.