Configuring application health check on the VM
To increase application availability and make sure that an application is responding, you can configure application health checks on a virtual machine. Instance Groups will perform a check and automatically recover a virtual machine if it fails. This is not to be confused with a network load balancer health check. Learn more about automatic recovery and types of checks.
This section describes how to set up 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 the Activate option.
- Set up the health checks:
-
Type:
HTTP
orTCP
. -
Path (for HTTP): The URL path for the HTTP check requests sent from Instance Groups.
-
Port: Port in the range 1-32767 to receive health check requests from Instance Groups.
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 a higher value here than in the load balancer. -
Interval in sec: Check interval, in seconds (this is the interval between health checks performs by Instance Groups).
-
Healthy threshold: Number of successful health checks required for the instance to be considered healthy.
If you connected your group to a network load balancer, we recommend setting a lower value here than in the load balancer. -
Unhealthy threshold: Number of failed health checks for the instance to be considered unhealthy.
If you connected your group to a network load balancer, we recommend setting a higher value here than in the load balancer.
-
- Click Save.
If you do not have the Yandex Cloud command line interface yet, install and initialize it.
The folder specified in the CLI profile is used by default. You can specify a different folder using the --folder-name
or --folder-id
parameter.
-
View a description of the update group command in the CLI:
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 the group
ID
orNAME
, e.g.,first-instance-group
. -
Get information about the instance group.
-
Create a YAML file with any name (for example,
group.yaml
) and, based on the information received, describe: -
Add a health check specification to the file (for example, 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 specs. http_options
Settings for HTTP health checks. Only HTTP/1.1 and lower are supported.
If you want to use TCP, then in thetcp_options
property specify the port number only.port
The port in the range 1-32767 to receive the check requests from Instance Groups. path
The URL path for the HTTP health check requests sent from Instance Groups. interval
Check interval in seconds: This is the interval between the health checks done by Instance Groups. timeout
Response timeout in seconds.
If you connected your group to a load balancer, we recommend setting a higher value here than in the load balancer.unhealthy_threshold
Unhealthy threshold is the number of failed health checks after which the instance is considered non-functional.
If you connected your group to a network load balancer, we recommend setting a higher value here than in the load balancer.healthy_threshold
Healthy threshold is the number of successful health checks after which an instance is considered functional.
If you connected your group to a load balancer, we recommend setting a lower value here than in 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 launch the instance group update process.