Skip to content

Target groups

The addresses a listener sends connections to, how they're checked, and how a backend gets the client's address.

Updated View as Markdown

A target group holds the addresses a listener sends connections to, and says how they’re checked. It belongs to one VPC, and serves one load balancer at most. Create one with CreateTargetGroup, or:

ezgh lb target-groups create web --vpc vpc_5p7r9s3t1vxz --port 8080

A target group’s protocol is tcp (the default), for tcp and tls listeners, or http, for http and https listeners (Route HTTP traffic). It can’t change after create.

Targets

A target is one of:

  • a private network interface in the VPC (eni_…). If its instance stops, the target is unused until the interface is bound again;
  • a private IPv4 address in the VPC. Use this for addresses that aren’t an interface’s primary one.

--port overrides the group’s port for one target. An interface or address can be a target of any number of groups.

ezgh lb targets register tgp_7t3n1v8c2wzd --network-interface eni_7hq2m0x9ka3c
ezgh lb targets register tgp_7t3n1v8c2wzd --private-ipv4 10.0.2.40 --port 9000
State Means
initial Just registered, and not checked yet.
healthy Passing its health checks, and taking connections.
unhealthy Failing them. It takes no new connections unless every target in the group is unhealthy.
unused Its interface isn’t bound to a running instance.
draining Deregistered, and finishing its open connections.
Reason Means
health_check_timed_out No answer. Usually a firewall.
connection_refused Nothing is listening on the port.
bad_response An HTTP or HTTPS check got a status it doesn’t accept.
instance_stopped The target’s instance stopped.
deregistering It was deregistered.

Health checks

Setting Default Range
Protocol tcp tcp, http, https
Port The target’s 1 to 65535
Interval 5 seconds 2 to 300
Timeout 2 seconds 1 to 120, below the interval
Healthy after 3 checks 1 to 10
Unhealthy after 2 checks 1 to 10
Path (http, https) /
Status codes (http, https) 200-399 A code or a range
ezgh lb target-groups create api --vpc vpc_5p7r9s3t1vxz --port 9000 \
  --health-check-protocol http --health-check-path /healthz

What a target sees

Connections reach a target from an address in the load balancer’s subnet, not from the client. To get the client’s address, set proxyProtocol to v2: each connection then starts with a PROXY protocol v2 header. A target that doesn’t speak it fails, so enable it on the target first.

An http target group passes the client’s address in X-Forwarded-For instead, with X-Forwarded-Proto and X-Forwarded-Port, so it takes no PROXY protocol. The load balancer adds the client to the end of any X-Forwarded-For the client sent, so trust only the last entry.

Deregistering

ezgh lb targets deregister tgp_7t3n1v8c2wzd 0199f000-0000-7000-8000-000000000a05

A deregistered target takes no new connections and stays draining until the group’s deregistration delay ends (300 seconds by default, 0 to 3600), so its open connections can finish. In a group no listener uses, or when it’s unused, it goes at once.

Deleting

A target group a listener uses can’t be deleted: 409 target_group_in_use.

Navigation

Type to search…

↑↓ navigate↵ selectEsc close