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 you need. - 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:
HTTP
orTCP
. -
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 yet, install and initialize it.
The folder specified in the CLI profile is used by default. You can specify a different folder through the --folder-name
or --folder-id
parameter.
-
See the description of the CLI command for updating an instance group:
yc compute instance-group update --help
-
Get a list of instance groups in the default folder:
yc compute instance-group list
Result:
+----------------------+-----------------------+------+ | ID | NAME | SIZE | +----------------------+-----------------------+------+ | amc65sbgfqeq******** | first-instance-group | 2 | +----------------------+-----------------------+------+
-
Select
ID
orNAME
of 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_specs
Health check specification http_options
Settings 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_options
property.port
Port in the range of 1 to 32767 Instance Groups will use to send check requests on. path
URL path Instance Groups will use to send HTTP check requests. interval
Interval between app health checks run by Instance Groups, in seconds. timeout
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.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.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. -
Update the instance group in the default folder:
yc compute instance-group update --name first-group --file group.yaml
Instance Groups will initiate instance group updating.