Configure application health check on the instance

    To make the application more available and make sure that it responds to requests, you can set up the application health check on the instance. Instance Groups will check and automatically recover the instance if it fails the check. Don't confuse this with the health check in the load balancer. Read more about automatic recovery and types of checks.

    This section describes how to set up application health check for an existing group.

    1. Open the folder page in the management console.

    2. Select Yandex Compute Cloud.

    3. On the Virtual machines page, go to the Instance groups tab.

    4. Select the group to update.

    5. In the Health checks section, enable the Activate option to the right.

    6. Select the protocol for the health checks: HTTP or TCP.

    7. Set up the health checks:

      • The port in the range 1-32767 to receive the check requests from Instance Groups.

      • Path (for HTTP) — The URL path for the HTTP check requests sent from Instance Groups.

        Alert

        Only HTTP/1.1 and lower are supported.

      • The response timeout in seconds.

        If you have connected your instance group to a load balancer, we recommend setting a smaller value here than in the load balancer.

      • Check interval in seconds — This is the interval for Instance Groups to wait between health checks.

      • Performance threshold — The number of successful health checks required for the managed instance to be considered healthy.

        If you have connected your instance group to a load balancer, we recommend that you set a smaller value here than in the load balancer.

      • Failure threshold — The number of failed health checks for the managed instance to be considered unhealthy.

        If you have connected your instance group to a load balancer, we recommend that you set a higher value here than in the load balancer.

    8. Click Save changes.

    If you don't have the Yandex.Cloud command line interface yet, install 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.

    1. View a description of the update group command in the CLI:

      $ yc compute instance-group update --help
      
    2. Get a list of instance groups in the default folder:

      $ yc compute instance-group list
      +----------------------+-----------------------+------+
      |          ID          |         NAME          | SIZE |
      +----------------------+-----------------------+------+
      | amc65sbgfqeqf00m02sc | first-instance-group  |    2 |
      +----------------------+-----------------------+------+
      

      Fields:

      Field Value
      ID Group ID.
      NAME Group name.
      SIZE Group size.
    3. Select the group ID or NAME (for example, first-instance-group).

    4. Get information about the instance group.

    5. Create a YAML file with any name (for example, group.yaml) and, based on the information received, describe:

    6. 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 the tcp_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 for Instance Groups to wait between health checks.
      timeout Response waiting time in seconds.
      If you have connected your instance group to a load balancer, we recommend setting a smaller value here than in the load balancer.
      unhealthy_threshold Unhealthy threshold — The number of failed health checks after which the instance is considered inoperable.
      If you have connected your instance group to a load balancer, we recommend that you set a higher value here than in the load balancer.
      healthy_threshold Healthy threshold — The number of successful health checks after which the instance is considered operable.
      If you have connected your instance group to a load balancer, we recommend that you set a smaller value here than in the load balancer.
    7. Update the instance group in the default folder:

      $ yc compute instance-group update --name first-group --file group.yaml
      

      Instance Groups starts the operation to update the instance group.