Registering VMs with a Load Balancer

You can register virtual machines (VMs) with a load balancer to route the inbound traffic to them. These VMs are called backend VMs. The load balancer only routes inbound traffic to its healthy registered VMs.

You can register additional VMs with a load balancer at any time to handle an increase of the traffic load sent to your backend VMs.

To register backend VMs using their public IPs rather than their VM IDs, see the OSC CLI section.

Registering VMs with a Load Balancer Using Cockpit v2

  1. In the Load Balancers dashboard, click the name of the load balancer you want to register a VM with.
    The load balancer details panel appears.

  2. Click on the Backend VMs tab and then click on IconAddFull Update.
    The UPDATE BACKEND VMS dialog box appears.

  3. From the VMs list, select one or more VMs you want to register with the load balancer.

  4. Click Update.
    The VM is registered with the load balancer.

Registering VMs with a Load Balancer Using OSC CLI

The LinkLoadBalancerBackendMachines command attaches one or more virtual machines (VMs) to a specified load balancer. You need to specify at least the BackendIps or the BackendVmIds parameter.
The VMs can be in different Subnets and different Subregions than the load balancer, as long as the VMs and load balancers are all in the public Cloud or all in the same Net. It may take a little time for a VM to be registered with the load balancer. Once the VM is registered with a load balancer, it receives traffic and requests from this load balancer and is called a backend VM.

Request sample: Linking VMs to a load balancer
$ osc-cli api LinkLoadBalancerBackendMachines --profile "default" \
    --LoadBalancerName "example-lbu" \
    --BackendVmIds '["i-12345678", "i-87654321"]'
Request sample: Linking public IPs to a load balancer
$ osc-cli api LinkLoadBalancerBackendMachines --profile "default" \
    --LoadBalancerName "example-lbu" \
    --BackendIps '["192.0.2.0", "198.51.100.0"]'

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

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

  • BackendVmIds: (optional) One or more IDs of backend VMs.

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

  • LoadBalancerName: The name of the load balancer.

The LinkLoadBalancerBackendMachines command returns the following elements:

  • ResponseContext: Information about the context of the response.

Result sample: Linking VMs to a load balancer
{
  "ResponseContext": {
    "RequestId": "0475ca1e-d0c5-441d-712a-da55a4175157"
  }
}
Result sample: Linking public IPs to a load balancer
{
  "ResponseContext": {
    "RequestId": "0475ca1e-d0c5-441d-712a-da55a4175157"
  }
}

Registering Instances with a Load Balancer Using AWS CLI

To register one or more instances, use the register-instances-with-load-balancer command following this syntax:

Request sample
$ aws elb register-instances-with-load-balancer \
    --profile YOUR_PROFILE \
    --load-balancer-name LB_NAME \
    --instances i-01234567 \
    --endpoint https://lbu.eu-west-2.outscale.com

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

  • (optional) profile: The named profile you want to use, created when configuring AWS CLI. For more information, see Installing and Configuring AWS CLI.

  • load-balancer-name: The name of the load balancer.

  • instances: One or more instance IDs.

  • endpoint: The endpoint corresponding to the Region you want to send the request to.

The register-instances-with-load-balancer command returns the following elements:

  • Instances: Information about one or more registered instance. This element contains the following information for each registered instance:

    • InstanceId: The ID of the instance.

Result sample
 {
   "Instances":
       {
           "InstanceId": "i-01234567"
       },
}

The specified instances are registered with the load balancer.

Related Pages

Corresponding API Methods

AWS™ and Amazon Web Services™ are trademarks of Amazon Technologies, Inc or its affiliates in the United States and/or other countries.