Configurer les health checks

Vous pouvez configurer des health checks pour vérifier périodiquement la disponibilité et la santé des machines virtuelles (VM) du load balancer afin d’envoyer les requêtes uniquement vers celles saines et disponibles. Vous pouvez configurer uniquement un type de health check par load balancer en spécifiant le port et le protocole des VM backend à vérifier.

Les health checks consistent à envoyer régulièrement des requêtes aux VM backend à intervalles de temps spécifiés. Une VM backend est considérée saine ou non saine selon un nombre de requêtes consécutives réussies ou non réussies que vous spécifiez. Une requête est considérée comme non réussie lorsqu’une VM ne répond pas à celle-ci dans un intervalle de temps que vous spécifiez également. Lorsqu’une VM considérée précédemment comme non saine redevient saine, le load balancer lui envoie à nouveau des requêtes de manière automatique sans action de votre part.

Configurer les health checks avec Cockpit v2

Configurer les health checks avec OSC CLI

À ce jour, cette section est disponible en anglais uniquement.

The UpdateLoadBalancer command modifies the specified attribute of a load balancer. You can specify only one attribute at a time.

You can set a new SSL certificate to an SSL or HTTPS listener of a load balancer.
This certificate replaces any certificate used on the same load balancer and port.

You can also replace the currently enabled policy for the load balancer with another one.
If the PolicyNames parameter is empty, the currently enabled policy is disabled.

Request sample: Updating health checks
$ osc-cli api UpdateLoadBalancer --profile "default" \
    --LoadBalancerName "private-lb-example" \
    --HealthCheck '{
        "HealthyThreshold": 10,
        "CheckInterval": 30,
        "Path": "/index.html",
        "Port": 8080,
        "Protocol": "HTTPS",
        "Timeout": 5,
        "UnhealthyThreshold": 5
      }'

This command contains the following attributes that you need to specify:

  • DryRun: (optional) If true, checks whether you have the required permissions to perform the action.

  • HealthCheck: (optional) Information about the health check configuration.

    • CheckInterval: The number of seconds between two requests (between 5 and 600 both included).

    • HealthyThreshold: The number of consecutive successful requests before considering the VM as healthy (between 2 and 10 both included).

    • Path: (optional) If you use the HTTP or HTTPS protocols, the request URL path.

    • Port: The port number (between 1 and 65535, both included).

    • Protocol: The protocol for the URL of the VM (HTTP | HTTPS | TCP | SSL).

    • Timeout: The maximum waiting time for a response before considering the VM as unhealthy, in seconds (between 2 and 60 both included).

    • UnhealthyThreshold: The number of consecutive failed requests before considering the VM as unhealthy (between 2 and 10 both included).

  • LoadBalancerName: The name of the load balancer.

The UpdateLoadBalancer command returns the following elements:

  • LoadBalancer: Information about the load balancer.

    • AccessLog: Information about access logs.

      • IsEnabled: If true, access logs are enabled for your load balancer. If false, they are not. If you set this to true in your request, the OsuBucketName parameter is required.

      • OsuBucketName: The name of the OOS bucket for the access logs.

      • OsuBucketPrefix: The path to the folder of the access logs in your OOS bucket (by default, the root level of your bucket).

      • PublicationInterval: The time interval for the publication of access logs in the OOS bucket, in minutes. This value can be either 5 or 60 (by default, 60).

    • ApplicationStickyCookiePolicies: The stickiness policies defined for the load balancer.

      • CookieName: The name of the application cookie used for stickiness.

      • PolicyName: The mnemonic name for the policy being created. The name must be unique within a set of policies for this load balancer.

    • BackendIps: One or more public IPs of backend VMs.

    • BackendVmIds: One or more IDs of backend VMs for the load balancer.

    • DnsName: The DNS name of the load balancer.

    • HealthCheck: Information about the health check configuration.

      • CheckInterval: The number of seconds between two requests (between 5 and 600 both included).

      • HealthyThreshold: The number of consecutive successful requests before considering the VM as healthy (between 2 and 10 both included).

      • Path: If you use the HTTP or HTTPS protocols, the request URL path.

      • Port: The port number (between 1 and 65535, both included).

      • Protocol: The protocol for the URL of the VM (HTTP | HTTPS | TCP | SSL).

      • Timeout: The maximum waiting time for a response before considering the VM as unhealthy, in seconds (between 2 and 60 both included).

      • UnhealthyThreshold: The number of consecutive failed requests before considering the VM as unhealthy (between 2 and 10 both included).

    • Listeners: The listeners for the load balancer.

      • BackendPort: The port on which the backend VM is listening (between 1 and 65535, both included).

      • BackendProtocol: The protocol for routing traffic to backend VMs (HTTP | HTTPS | TCP | SSL).

      • LoadBalancerPort: The port on which the load balancer is listening (between 1 and 65535, both included).

      • LoadBalancerProtocol: The routing protocol (HTTP | HTTPS | TCP | SSL).

      • PolicyNames: The names of the policies. If there are no policies enabled, the list is empty.

      • ServerCertificateId: The OUTSCALE Resource Name (ORN) of the server certificate. For more information, see Resource Identifiers > OUTSCALE Resource Names (ORNs).

    • LoadBalancerName: The name of the load balancer.

    • LoadBalancerStickyCookiePolicies: The policies defined for the load balancer.

      • CookieExpirationPeriod: The time period, in seconds, after which the cookie should be considered stale.
        If 1, the stickiness session lasts for the duration of the browser session.

      • PolicyName: The name of the stickiness policy.

    • LoadBalancerType: The type of load balancer. Valid only for load balancers in a Net.
      If LoadBalancerType is internet-facing, the load balancer has a public DNS name that resolves to a public IP.
      If LoadBalancerType is internal, the load balancer has a public DNS name that resolves to a private IP.

    • NetId: The ID of the Net for the load balancer.

    • PublicIp: (internet-facing only) The public IP associated with the load balancer.

    • SecuredCookies: Whether secure cookies are enabled for the load balancer.

    • SecurityGroups: One or more IDs of security groups for the load balancers. Valid only for load balancers in a Net.

    • SourceSecurityGroup: Information about the source security group of the load balancer, which you can use as part of your inbound rules for your registered VMs.
      To only allow traffic from load balancers, add a security group rule that specifies this source security group as the inbound source.

      • SecurityGroupAccountId: The account ID of the owner of the security group.

      • SecurityGroupName: The name of the security group.

    • Subnets: The ID of the Subnet in which the load balancer was created.

    • SubregionNames: The ID of the Subregion in which the load balancer was created.

    • Tags: One or more tags associated with the load balancer.

      • Key: The key of the tag, with a minimum of 1 character.

      • Value: The value of the tag, between 0 and 255 characters.

  • ResponseContext: Information about the context of the response.

    • RequestId: The ID of the request.

Result sample: Updating health checks
{
  "ResponseContext": {
    "RequestId": "0475ca1e-d0c5-441d-712a-da55a4175157"
  },
  "LoadBalancer": {
    "Tags": [],
    "SourceSecurityGroup": {
      "SecurityGroupName": "security-group-example",
      "SecurityGroupAccountId": "123456789012"
    },
    "SecuredCookies": false,
    "PublicIp": "192.0.2.0",
    "Subnets": [
      "subnet-12345678"
    ],
    "NetId": "vpc-12345678",
    "BackendVmIds": [],
    "ApplicationStickyCookiePolicies": [],
    "SecurityGroups": [
      "sg-12345678"
    ],
    "LoadBalancerType": "internet-facing",
    "AccessLog": {
      "PublicationInterval": 60,
      "IsEnabled": false
    },
    "DnsName": "private-lb-example.123456789.eu-west-2.lbu.outscale.com",
    "HealthCheck": {
      "UnhealthyThreshold": 5,
      "Timeout": 5,
      "CheckInterval": 30,
      "Path": "/index.html",
      "Protocol": "HTTPS",
      "HealthyThreshold": 10,
      "Port": 8080
    },
    "LoadBalancerStickyCookiePolicies": [],
    "SubregionNames": [
      "eu-west-2a"
    ],
    "Listeners": [
      {
        "ServerCertificateId": "orn:ows:idauth::012345678910:server-certificate/Certificate",
        "BackendPort": 80,
        "BackendProtocol": "HTTP",
        "LoadBalancerPort": 443,
        "LoadBalancerProtocol": "HTTPS"
      }
    ],
    "LoadBalancerName": "private-lb-example"
  }
}

Configurer les health checks avec oapi-cli

À ce jour, cette section est disponible en anglais uniquement.

The UpdateLoadBalancer command modifies the specified attribute of a load balancer. You can specify only one attribute at a time.

You can set a new SSL certificate to an SSL or HTTPS listener of a load balancer.
This certificate replaces any certificate used on the same load balancer and port.

You can also replace the currently enabled policy for the load balancer with another one.
If the PolicyNames parameter is empty, the currently enabled policy is disabled.

Request sample: Updating health checks
$ oapi-cli --profile "default" UpdateLoadBalancer \
    --LoadBalancerName "private-lb-example" \
    --HealthCheck '{
        "HealthyThreshold": 10,
        "CheckInterval": 30,
        "Path": "/index.html",
        "Port": 8080,
        "Protocol": "HTTPS",
        "Timeout": 5,
        "UnhealthyThreshold": 5
      }'

This command contains the following attributes that you need to specify:

  • DryRun: (optional) If true, checks whether you have the required permissions to perform the action.

  • HealthCheck: (optional) Information about the health check configuration.

    • CheckInterval: The number of seconds between two requests (between 5 and 600 both included).

    • HealthyThreshold: The number of consecutive successful requests before considering the VM as healthy (between 2 and 10 both included).

    • Path: (optional) If you use the HTTP or HTTPS protocols, the request URL path.

    • Port: The port number (between 1 and 65535, both included).

    • Protocol: The protocol for the URL of the VM (HTTP | HTTPS | TCP | SSL).

    • Timeout: The maximum waiting time for a response before considering the VM as unhealthy, in seconds (between 2 and 60 both included).

    • UnhealthyThreshold: The number of consecutive failed requests before considering the VM as unhealthy (between 2 and 10 both included).

  • LoadBalancerName: The name of the load balancer.

The UpdateLoadBalancer command returns the following elements:

  • LoadBalancer: Information about the load balancer.

    • AccessLog: Information about access logs.

      • IsEnabled: If true, access logs are enabled for your load balancer. If false, they are not. If you set this to true in your request, the OsuBucketName parameter is required.

      • OsuBucketName: The name of the OOS bucket for the access logs.

      • OsuBucketPrefix: The path to the folder of the access logs in your OOS bucket (by default, the root level of your bucket).

      • PublicationInterval: The time interval for the publication of access logs in the OOS bucket, in minutes. This value can be either 5 or 60 (by default, 60).

    • ApplicationStickyCookiePolicies: The stickiness policies defined for the load balancer.

      • CookieName: The name of the application cookie used for stickiness.

      • PolicyName: The mnemonic name for the policy being created. The name must be unique within a set of policies for this load balancer.

    • BackendIps: One or more public IPs of backend VMs.

    • BackendVmIds: One or more IDs of backend VMs for the load balancer.

    • DnsName: The DNS name of the load balancer.

    • HealthCheck: Information about the health check configuration.

      • CheckInterval: The number of seconds between two requests (between 5 and 600 both included).

      • HealthyThreshold: The number of consecutive successful requests before considering the VM as healthy (between 2 and 10 both included).

      • Path: If you use the HTTP or HTTPS protocols, the request URL path.

      • Port: The port number (between 1 and 65535, both included).

      • Protocol: The protocol for the URL of the VM (HTTP | HTTPS | TCP | SSL).

      • Timeout: The maximum waiting time for a response before considering the VM as unhealthy, in seconds (between 2 and 60 both included).

      • UnhealthyThreshold: The number of consecutive failed requests before considering the VM as unhealthy (between 2 and 10 both included).

    • Listeners: The listeners for the load balancer.

      • BackendPort: The port on which the backend VM is listening (between 1 and 65535, both included).

      • BackendProtocol: The protocol for routing traffic to backend VMs (HTTP | HTTPS | TCP | SSL).

      • LoadBalancerPort: The port on which the load balancer is listening (between 1 and 65535, both included).

      • LoadBalancerProtocol: The routing protocol (HTTP | HTTPS | TCP | SSL).

      • PolicyNames: The names of the policies. If there are no policies enabled, the list is empty.

      • ServerCertificateId: The OUTSCALE Resource Name (ORN) of the server certificate. For more information, see Resource Identifiers > OUTSCALE Resource Names (ORNs).

    • LoadBalancerName: The name of the load balancer.

    • LoadBalancerStickyCookiePolicies: The policies defined for the load balancer.

      • CookieExpirationPeriod: The time period, in seconds, after which the cookie should be considered stale.
        If 1, the stickiness session lasts for the duration of the browser session.

      • PolicyName: The name of the stickiness policy.

    • LoadBalancerType: The type of load balancer. Valid only for load balancers in a Net.
      If LoadBalancerType is internet-facing, the load balancer has a public DNS name that resolves to a public IP.
      If LoadBalancerType is internal, the load balancer has a public DNS name that resolves to a private IP.

    • NetId: The ID of the Net for the load balancer.

    • PublicIp: (internet-facing only) The public IP associated with the load balancer.

    • SecuredCookies: Whether secure cookies are enabled for the load balancer.

    • SecurityGroups: One or more IDs of security groups for the load balancers. Valid only for load balancers in a Net.

    • SourceSecurityGroup: Information about the source security group of the load balancer, which you can use as part of your inbound rules for your registered VMs.
      To only allow traffic from load balancers, add a security group rule that specifies this source security group as the inbound source.

      • SecurityGroupAccountId: The account ID of the owner of the security group.

      • SecurityGroupName: The name of the security group.

    • Subnets: The ID of the Subnet in which the load balancer was created.

    • SubregionNames: The ID of the Subregion in which the load balancer was created.

    • Tags: One or more tags associated with the load balancer.

      • Key: The key of the tag, with a minimum of 1 character.

      • Value: The value of the tag, between 0 and 255 characters.

  • ResponseContext: Information about the context of the response.

    • RequestId: The ID of the request.

Result sample: Updating health checks
{
  "ResponseContext": {
    "RequestId": "0475ca1e-d0c5-441d-712a-da55a4175157"
  },
  "LoadBalancer": {
    "Tags": [],
    "SourceSecurityGroup": {
      "SecurityGroupName": "security-group-example",
      "SecurityGroupAccountId": "123456789012"
    },
    "SecuredCookies": false,
    "PublicIp": "192.0.2.0",
    "Subnets": [
      "subnet-12345678"
    ],
    "NetId": "vpc-12345678",
    "BackendVmIds": [],
    "ApplicationStickyCookiePolicies": [],
    "SecurityGroups": [
      "sg-12345678"
    ],
    "LoadBalancerType": "internet-facing",
    "AccessLog": {
      "PublicationInterval": 60,
      "IsEnabled": false
    },
    "DnsName": "private-lb-example.123456789.eu-west-2.lbu.outscale.com",
    "HealthCheck": {
      "UnhealthyThreshold": 5,
      "Timeout": 5,
      "CheckInterval": 30,
      "Path": "/index.html",
      "Protocol": "HTTPS",
      "HealthyThreshold": 10,
      "Port": 8080
    },
    "LoadBalancerStickyCookiePolicies": [],
    "SubregionNames": [
      "eu-west-2a"
    ],
    "Listeners": [
      {
        "ServerCertificateId": "orn:ows:idauth::012345678910:server-certificate/Certificate",
        "BackendPort": 80,
        "BackendProtocol": "HTTP",
        "LoadBalancerPort": 443,
        "LoadBalancerProtocol": "HTTPS"
      }
    ],
    "LoadBalancerName": "private-lb-example"
  }
}

Configurer les health checks avec AWS CLI

Avant de commencer : Installez et configurez AWS CLI. Pour en savoir plus, voir Installer et configurer AWS CLI.

Pour configurer les health checks d’un load balancer, utilisez la commande configure-health-check en suivant cette syntaxe :

Exemple de requête
$ aws elb configure-health-check \
    --profile YOUR_PROFILE \
    --load-balancer-name LB_NAME \
    --health-check Target=HTTP:80/home/index.html,Interval=60,Timeout=5,UnhealthyThreshold=5,HealthyThreshold=2 \
    --endpoint https://lbu.eu-west-2.outscale.com

Cette commande contient les attributs suivants que vous devez spécifier :

  • (optionnel) profile : Le profil nommé que vous voulez utiliser, créé pendant la configuration d’AWS CLI. Pour en savoir plus, voir Installer et configurer AWS CLI.

  • load-balancer-name : Le nom du load balancer.

  • health-check : La configuration pour les health checks. Cet attribut contient les éléments suivants qui vous devez spécifier :

    • Target : Le port et le protocole pour les instances backend ciblées par les health checks, au format protocol:port/path.

      Vous pouvez taper les valeurs suivantes :

      • Protocol : TCP, SSL, HTTP ou HTTPS

      • Port : entre 1 et 65535 (tous deux inclus)

      • Path : Si vous utilisez les protocoles HTTP ou HTTPS, le chemin URL de la requête (par exemple, HTTP:80/index.html)

    • Interval : Le nombre de secondes entre deux requêtes (entre 5 et 600 tous deux inclus, par défaut 30).

    • Timeout : Le temps d’attente maximum d’une réponse avant de considérer la requête comme non réussie, en secondes (entre 2 et 60 tous deux inclus, par défaut 5).

    • UnhealthyThreshold : Le nombre de requêtes non réussies consécutives pour considérer l’instance comme non saine (entre 2 et 10 tous deux inclus, par défaut 2).

    • HealthyThreshold : Le nombre de requêtes réussies consécutives nécessaires pour considérer l’instance comme saine (entre 2 et 10 tous deux inclus, par défaut 10).

  • endpoint : Le endpoint correspondant à la Région à laquelle vous voulez envoyer la requête. Pour en savoir plus, voir Installer et configurer AWS CLI.

La commande configure-health-check renvoie les éléments suivants :

  • HealthCheck : Informations à propos des health checks mis à jour. Cet élément contient les informations suivantes :

    • HealthyThreshold : Le nombre de requêtes réussies consécutives nécessaires pour considérer l’instance comme saine.

    • Interval : Le nombre de secondes entre deux requêtes.

    • Target : Le port et le protocole pour les instances backend ciblées par les health checks, et le chemin URL de la requête si vous utilisez le protocole HTTP.

    • Timeout : Le temps d’attente maximum d’une réponse avant de considérer la requête comme non réussie, en secondes.

    • UnhealthyThreshold : Le nombre de requêtes non réussies consécutives pour considérer l’instance comme non saine.

Exemple de résultat
{
   "HealthCheck": {
       "HealthyThreshold": 2,
       "Interval": 60,
       "Target": "HTTP:80/home/index.html",
       "Timeout": 5,
       "UnhealthyThreshold": 5
   }
}

Les health checks sont configurés pour le load balancer.

Méthodes API correspondantes

Pages connexes

AWS™ et Amazon Web Services™ sont des marques de commerce d'Amazon Technologies, Inc. ou de ses affiliées aux États-Unis et/ou dans les autres pays.