Menu
Elastic Load Balancing
Developer Guide

Register or De-Register EC2 Instances for Your Load Balancer

Registering an EC2 instance adds it to your load balancer. The load balancer continuously monitors the health of registered instances in its enabled Availability Zones, and routes requests to the instances that are healthy. If demand on your instances increases, you can register additional instances with the load balancer to handle the demand.

De-registering an EC2 instance removes it from your load balancer. The load balancer stops routing requests to an instance as soon as it is de-registered. If demand decreases, or you need to service your instances, you can de-register instances from the load balancer. A de-registered instance remains running, but no longer receives traffic from the load balancer, and you can register it with the load balancer again when you are ready.

When you de-register an instance, Elastic Load Balancing waits until in-flight requests have completed if connection draining is enabled. For more information, see Configure Connection Draining for Your Load Balancer.

If your load balancer is attached to an Auto Scaling group, instances added to the group are automatically registered with the load balancer and instances removed from the group are automatically de-registered from the load balancer. For more information, see Load Balance Your Auto Scaling Group.

Elastic Load Balancing registers your EC2 instance with your load balancer using its IP address.

[EC2-VPC] When you register an instance with an elastic network interface (ENI) attached, the load balancer routes requests to the primary IP address of the primary interface (eth0) of the instance.

Prerequisites

The instance must be a running instance in the same network as the load balancer (EC2-Classic or the same VPC). If you have EC2-Classic instances and a load balancer in a VPC with ClassicLink enabled, you can link the EC2-Classic instances to that VPC and then register them with a load balancer in the VPC.

Register an Instance

When you are ready, register your instance with your load balancer. If the instance is an in Availability Zone that is enabled for the load balancer, the instance is ready to receive traffic from the load balancer as soon as it passes the required number of health checks.

To register your instances using the console

  1. Open the Amazon EC2 console at https://console.aws.amazon.com/ec2/.

  2. On the navigation pane, under LOAD BALANCING, choose Load Balancers.

  3. Select your load balancer.

  4. In the bottom pane, select the Instances tab.

  5. Click Edit Instances.

  6. Select the instance to register with your load balancer.

  7. Click Save.

To register your instances using the AWS CLI

Use the following register-instances-with-load-balancer command:

aws elb register-instances-with-load-balancer --load-balancer-name my-loadbalancer --instances i-4e05f721

The following is an example response that lists the instances registered with the load balancer:

{
    "Instances": [
        {
            "InstanceId": "i-315b7e51"
        }, 
        {
            "InstanceId": "i-4e05f721"
        }
    ]
}

De-register an Instance

You can de-register a back-end instance from your load balancer if you no longer need the capacity or if you need to service the instance.

To de-register your instances using the console

  1. Open the Amazon EC2 console at https://console.aws.amazon.com/ec2/.

  2. On the navigation pane, under LOAD BALANCING, choose Load Balancers.

  3. Select your load balancer.

  4. In the bottom pane, select the Instances tab.

  5. In Actions column for the instance to de-register, click Remove from Load Balancer.

  6. When prompted for confirmation, click Yes, Remove.

To de-register your instances using the AWS CLI

Use the following deregister-instances-from-load-balancer command:

aws elb deregister-instances-from-load-balancer --load-balancer-name my-loadbalancer --instances i-4e05f721

The following is an example response that lists the remaining instances registered with the load balancer:

{
    "Instances": [
        {
            "InstanceId": "i-315b7e51"
        }
    ]
}