Target Groups
In this article:
Target Groups#
One or more target groups must be created for the load balancer to work. Each target group includes one or more targets among which requests are distributed. The target is identified by a combination of instance ID and port number.
Traffic is routed to the target group specified in the traffic listener. To balance different request types, you can create multiple listeners and corresponding target groups. Routing is performed independently for each target group.
The same target group can be used by several listeners, but only by one load balancer. In other words, all listeners using a particular target group must belong to the same load balancer.
You can add and remove targets from a target group. The same target resource can belong to different target groups.
Health check#
The target health check ensures that requests are only directed to active target resources. If necessary, you can modify the default settings.
The health check method employed depends on the target group type (TCP, UDP, or HTTP):
in case of a TCP target group, the load balancer expects to receive a
SYN-ACKpacket in response to aSYNrequest;in case of a UDP target group, the load balancer expects that a UDP packet will not return
ICMP Unreachable(Type 3with anyCodevalue);in case of an HTTP target group, the load balancer expects to receive a predefined HTTP code (by default,
200) in response to a health check request. You can configure an HTTP path for checking availability of targets and an HTTP response code, that indicates that the target is available.
If all registered targets in a target group are unavailable, the ALB returns HTTP 503 Service Unavailable in response to the user request, while the NLB ignores incoming requests.
Target state#
Based on the check results, the target may be in one of the following states.
State |
Description |
|---|---|
|
Target is healthy |
|
The target is unhealthy: it is not responding to requests, has failed a health check, or is stopped. |
|
The target is not registered in the target group, or the target group is not included in the listener rule. |
Target state codes#
If the target state is other than Ready, the cause can be found in the Targets tab on the target group page where its code and description are displayed. The state code can also be found using the DescribeTargetHealth API method.
State code |
Description |
|---|---|
Target.NotInUse |
The target group is not configured to receive traffic from the load balancer. |
Target.NotRegistered |
The target is not registered in the target group |
Target.Timeout |
Response timeout |
Target.ResponseCodeMismatch 1 |
Health check failed, code [code] |
Target.FailedHealthChecks 1 |
Health check failed |
Управление целевыми группами#
Create target group#
Note
Only instances in the Running state can be added to the target group. They must be in the same VPC as the load balancer to be associated with this target group.
To create a target group:
Go to the section Load Balancing Target Groups and click Create.
Specify target group parameters:
Name tag – Optional description of the target group.
Target group name – The name must not be longer than 32 characters, can only contain Latin letters, numbers and hyphens, and must not start or end with a hyphen.
Protocol – Protocol used to transmit traffic (TCP or UDP for a network load balancer and HTTP for an application load balancer). It must be the same as the protocol specified in the listener.
Port – The default port for receiving traffic. It will be assigned to the target if no other port is specified.
VPC – VPC in which targets are located.
To go to the next step, click Next.
Set the health check settings.
Note
For an HTTP target group, you can also use the ModifyTargetGroup API method to specify a path for checking the target availability and an HTTP response code indicating that the target is available.
Healthy threshold – The number of successful health checks before the resource is considered available.
Unhealthy threshold – The number of failed health checks before the resource is considered unavailable. In case of a network load balancer, this parameter is automatically set equal to the healthy threshold.
Interval – Period between health checks of a target.
Timeout – The time, after which the check is considered failed if there is no response. This value is for reference only and cannot be changed.
To go to the next step, click Next.
Register instances in a target group.
Note
Этот шаг можно пропустить и зарегистрировать целевые ресурсы позже.
Select instances from the drop-down list.
Change the default port if necessary. You can specify multiple ports separated by commas. In this case, a separate target with the selected port will be created for each selected instance.
Click Add to include instances with the specified ports in the target group.
Проверьте список добавляемых ресурсов. При необходимости можно сразу добавить дополнительные целевые ресурсы, повторив описанные выше действия, или удалить лишние, нажав Убрать целевые ресурсы.
To go to the next step, click Next.
If required, assign tags to the target group.
If the Name tag was not specified in step 2 and you want to add it, click Add Name tag and set the tag value.
To add an arbitrary tag, click Add tag and enter tag key and value.
To go to the next step, click Overview and Create.
Double-check all the set parameters and targets and click Create.
Register targets#
При необходимости в существующую целевую группу можно добавить дополнительные целевые ресурсы, например, когда их производительности становится недостаточно или какой-либо целевой ресурс становится недоступным.
Go to the section Load Balancing Target Groups.
Select the target group from the list and click Register resources. Alternatively, click the target group name to go to the group page, open the Targets tab, and click Register targets.
Add instances to the target group:
Select instances from the drop-down list.
Change the default port if necessary. You can specify multiple ports separated by commas. In this case, a separate target with the selected port will be created for each selected instance.
Click Add to include instances with the specified ports in the target group.
Проверьте список добавляемых ресурсов. При необходимости можно сразу добавить дополнительные целевые ресурсы, повторив описанные выше действия, или удалить лишние, нажав Удалить.
Click Register to register targets.
Change settings to check health#
Go to the section Load Balancing Target Groups.
Select the target group from the list and click Edit health check settings. Alternatively, click the target group name to go to the group page, open the Health check tab, and click Edit health check settings.
Edit the health check settings:
Note
For an HTTP target group, you can also use the ModifyTargetGroup API method to modify a path for checking the target availability and an HTTP response code indicating that the target is available.
Healthy threshold. For an NLB target group, the unhealthy threshold will be automatically modified and set equal to the healthy threshold.
Unhealthy threshold. For an NLB target group, the healthy threshold will be automatically modified and set equal to the unhealthy threshold.
Interval between health checks.
Click Modify to apply the new settings.
Deregister targets#
To exclude targets from the group:
Go to the section Load Balancing Target Groups.
Click the target group name to go to the group page and open the Targets tab.
Выберите в таблице целевые ресурсы, регистрацию которых необходимо отменить, и нажмите Отменить регистрацию.
Attention
The operation is performed without additional confirmation. If necessary, you can easily again register resources, which you deregistered.
Create a balancer with an associated target group#
Балансировщик нагрузки можно создать непосредственно в разделе Целевые группы. Он будет ассоциирован с выбранной целевой группой, так что задавать её параметры не потребуется. Данная возможность доступна только для групп, которые не ассоциированы с каким-либо обработчиком.
Note
An Internet-facing load balancer can only be created if the target group is placed in the VPC with an attached Internet gateway.
To create a balancer and associate it with a target group:
Go to the section Load Balancing Target Groups.
Select the target group from the resource table and click Create load balancer.
A balancer wizard opens. It is similar to the standard wizard. Follow steps 1 and 2 to configure the basic parameters and associate the balancer with a network.
Add listeners. You don’t need to specify a target group to which the listener forwards traffic, since the selected target group is used to this end. If forwarding to other target groups is required, it can be set up after creating the balancer by adding listeners. To add other listeners, click Add.
In the last step, check the configured load balancer parameters and click Create.
Add listener for a target group#
Добавить обработчик для выбранной целевой группы можно непосредственно в подразделе Целевые группы, при этом вам не потребуется задавать её параметры. Процедура добавления несколько отличается в зависимости от того, ассоциирована целевая группа с балансировщиком нагрузки или нет.
To add a listener:
Go to the section Load Balancing Target Groups.
Select the target group from the resource table and click Add listener.
If the group is not associated with any load balancer, select a load balancer from the drop-down list. Set the port the listener will use to receive traffic.
If you want to assign tags to the listener, click Add tags to go to the next step.
If the Name tag was not specified and you want to add it, click Add Name tag and set the tag value.
To add an arbitrary tag, click Add tag and enter tag key and value.
Click Add.
Delete target group#
Note
The target group can only be deleted if not used by any listener. Deleting a target group only deletes the group itself. Instances included in it as targets are not deleted.
To delete a target group:
Go to the section Load Balancing Target Groups.
Select the target group from the list and click Delete. Alternatively, click the target group name to go to the group page, open the Information tab, and click Delete.
To confirm the action, click Delete.
Alarm setup#
С помощью алармов можно настроить уведомления, когда параметры целевой группы выходят за заданные критические значения.
Important
Метрики собираются только для целевых групп HTTP, поэтому алармы можно настроить только для таких групп.
Create alarm#
Note
Alarm can also be created in the section Monitoring Alarms.
Go to the section Load Balancing Target Groups.
Найдите нужную целевую группу в таблице ресурсов и нажмите на имя ресурса для перехода на его страницу.
Open the Alarms tab and click Create.
In the window that opens, select the metrics to be monitored:
RequestCountPerTarget — Среднее количество запросов в расчёте на один работоспособный целевой ресурс.
HealthyHostCount — Количество работоспособных целевых ресурсов.
UnhealthyHostCount — Количество неработоспособных целевых ресурсов.
TargetConnectionErrorCount — Количество безуспешных попыток установить соединение между целевым ресурсом и балансировщиком нагрузки.
HTTPCode_Target_2xx_Count — Количество HTTP-кодов ответов 2xx.
HTTPCode_Target_3xx_Count — Количество HTTP-кодов ответов 3xx.
HTTPCode_Target_4xx_Count — Количество HTTP-кодов ответов 4xx.
HTTPCode_Target_5xx_Count — Количество HTTP-кодов ответов 5xx.
TargetResponseTime — Время ответа целевого ресурса.
Click Next.
Set alarm metrics (for details, see Alarms section):
имя аларма и, опционально, его описание;
статистику;
условие срабатывания аларма для выбранной метрики — оператор сравнения и пороговое значение;
количество периодов проверки метрики и их продолжительность.
При необходимости также можно поменять выбранную на предыдущем шаге метрику.
Опционально можно также указать адреса, на которые будут отправляться уведомления при изменении состояния аларма (см. подробнее раздел Алармы). Для этого перейдите на следующий шаг, нажав Настроить действия.
После выполнения всех необходимых настроек нажмите Создать.
Change the alarm#
To change the alarm:
Go to the section Load Balancing Target Groups.
Найдите нужную целевую группу в таблице ресурсов и нажмите на имя ресурса для перехода на его страницу.
Open the Alarms tab, select the desired alarm in the table and click Modify.
The dialog window will open at the Parameters step. Modify the required alarm parameters:
cтатистику;
условие срабатывания аларма для выбранной метрики — оператор сравнения и пороговое значение;
отслеживаемую метрику;
количество периодов проверки метрики и их продолжительность.
Если требуется изменить или отменить уже настроенные уведомления, либо добавить дополнительные адреса для уведомлений, нажмите Настроить действия для перехода на следующий шаг.
После внесения необходимых изменений нажмите Изменить для их сохранения.
Delete the alarm#
Go to the section Load Balancing Target Groups.
Найдите нужную целевую группу в таблице ресурсов и нажмите на имя ресурса для перехода на его страницу.
На вкладке Алармы выберите удаляемый аларм в таблице алармов. Одновременно можно выбрать несколько алармов.
Click Delete and confirm the action in the dialog window.
Target group information#
The resource page displays data about the target group, its resources, along with their quantities and parameters, health check settings, and other useful information. To open the specific target group page, go to the section Load balancing Target groups and click its name in the resource table.
The Information tab shows general information about the group:
target group name (Name tag);
type of targets included in it;
load balancer to which the group refers;
protocol used to transmit traffic to the target group;
port to which traffic is transmitted;
VPC in which the target group is created;
ARN of the target group;
number of targets in the group.
Кроме того, здесь можно создать балансировщик нагрузки, добавить обработчик и удалить группу.
The Targets tab displays a table with details of resources in the target group:
instance ID;
port at which traffic is received;
target status;
the reason why the target is in this status;
description of the reason.
Кроме того, здесь можно зарегистрировать дополнительные ресурсы или отменить регистрацию существующих ресурсов.
In the Health check tab, you can view the health check settings and modify some of them:
protocol used for health check;
port used for health check;
healthy threshold;
unhealthy threshold;
interval between health checks;
waiting time for a response, after which the check is considered failed.
На вкладке Метрики отображаются графики отслеживаемых метрик. Вы можете настроить период, для которого строятся графики метрики, статистику и интервал, с которым она рассчитывается. Для автоматического обновления графика включите опцию Автообновление, для обновления вручную нажмите Обновить.
Important
Automatic refresh is not possible when a custom period and/or interval is selected.
The Alarms tab displays details of alarms configured for the resource:
state;
alarm name;
triggering condition.
Alarms can be filtered by a state and/or metrics.
Кроме того, здесь можно создать, изменить или удалить алармы.
На вкладке Теги отображается информация о назначенных тегах. Кроме того, здесь можно также назначить теги целевой группе.