Configuring application health checks on a VM instance
By configuring app health checks on a VM instance, you can improve application availability and ensure its responsiveness. Instance Groups will run a check and automatically recover the instance if it fails it. Do not confuse this with a network load balancer health check. Learn more about automatic recovery and types of checks here.
This section describes how to configure an application health check for an existing group.
- In the management console
, open the folder containing the instance group in question. - Select Compute Cloud.
- In the left-hand panel, select
Instance groups. - Select the group to update.
- In the top-right corner of the page, click Edit.
- Under Health checks, enable Activate.
- Configure health check settings:
-
Type:
HTTPorTCP. -
Path (for HTTP): URL path Instance Groups will use to send HTTP check requests.
-
Port: Port in the range of 1 to 32767 Instance Groups will use to send check requests on.
Alert
Only HTTP/1.1 and lower are supported.
-
Timeout in sec: Response timeout in seconds.
If you connected your group to a network load balancer, we recommend setting this parameter to a higher value than the one for the load balancer. -
Interval in sec: Interval between app health checks run by Instance Groups, in seconds.
-
Healthy threshold: Number of successful health checks required to consider a VM instance healthy.
If you connected your group to a network load balancer, we recommend setting this parameter to a lower value than the one for the load balancer. -
Unhealthy threshold: Number of failed health checks required to consider a VM instance unhealthy.
If you connected your group to a network load balancer, we recommend setting this parameter to a higher value than the one for the load balancer.
-
- Click Save.
If you do not have the Yandex Cloud CLI installed yet, install and initialize it.
By default, the CLI uses the folder specified when creating the profile. To change the default folder, use the yc config set folder-id <folder_ID> command. You can also set a different folder for any specific command using the --folder-name or --folder-id parameter.
-
See the description of the CLI command for updating a group:
yc compute instance-group update --help -
Get a list of instance groups in the default folder:
yc compute instance-group listResult:
+----------------------+-----------------------+------+ | ID | NAME | SIZE | +----------------------+-----------------------+------+ | amc65sbgfqeq******** | first-instance-group | 2 | +----------------------+-----------------------+------+ -
Select
IDorNAMEof the group you need, e.g.,first-instance-group. -
Get information about the instance group.
-
Create a YAML file with any name, e.g.,
group.yaml, and define the following based on the info you get: -
Add a health check specification to the file, e.g, for HTTP checks:
... health_checks_spec: health_check_specs: - http_options: port: 80 path: / interval: 30s timeout: 10s unhealthy_threshold: 5 healthy_threshold: 3 ...Where:
Key Value health_check_specsHealth check specification http_optionsSettings for HTTP health checks. Only HTTP/1.1 and lower are supported.
If you want to use TCP, specify only the port number in thetcp_optionsproperty.portPort in the range of 1 to 32767 Instance Groups will use to send check requests on. pathURL path Instance Groups will use to send HTTP check requests. intervalInterval between app health checks run by Instance Groups, in seconds. timeoutResponse timeout in seconds.
If you connected your group to a network load balancer, we recommend setting this parameter to a higher value than the one for the load balancer.unhealthy_thresholdNumber of failed health checks required to consider a VM instance unhealthy.
If you connected your group to a network load balancer, we recommend setting this parameter to a higher value than the one for the load balancer.healthy_thresholdNumber of successful health checks required to consider a VM instance healthy.
If you connected your group to a network load balancer, we recommend setting this parameter to a lower value than the one for the load balancer. -
Update the instance group in the default folder:
yc compute instance-group update --name first-group --file group.yamlInstance Groups will initiate instance group updating.