--- title: "Connect an Auto Scaling Group" description: "Put an Auto Scaling Group behind a TIR Load Balancer from either side, and detach it again when it should stop taking traffic." content_type: "how-to" product: "tir-load-balancer" platform: "TIR" url: "/tir/tir-load-balancer/how-to/connect-an-auto-scaling-group/" topic: ["create-and-connect"] --- # Connect an Auto Scaling Group Connect an [Auto Scaling Group](/tir/tir-auto-scaling/) to a Load Balancer so that the Load Balancer sends traffic to the group's VMs. The Load Balancer is attached to the group itself, so traffic keeps following the group through every scale-up and scale-down. Only a web Load Balancer can have an Auto Scaling Group as a backend. ## Before you begin - A web Load Balancer. To make one, see [Create a Load Balancer](/tir/tir-load-balancer/how-to/create-a-load-balancer/). - An Auto Scaling Group in the **Running** state in the same project. - Permission to update Load Balancers in the project. See [TIR Access Control](/tir/tir-iam/). ## Connect from the Load Balancer 1. Open the Load Balancer and select the **Backend groups** tab. 2. Select **New group**. To change a group that exists, open **Edit** from its **Actions** menu. 3. Enter a **Name**, then choose the **Auto Scaling Group** tab among the backends. It lists the project's running Auto Scaling Groups, each with its name, how many VMs it is running, and the range it scales between. 4. Tick the group. The Auto Scaling Group is one backend, with a fixed port of 80 and a fixed weight of 1. 5. Select **Create group**. A backend group holds one kind of backend, so VMs and inference endpoints go in a separate group from an Auto Scaling Group. For the other settings of the group, see [Create a backend group](/tir/tir-load-balancer/how-to/create-a-backend-group/). Traffic reaches the group once a rule forwards to it; see [Add a rule](/tir/tir-load-balancer/how-to/add-a-rule/). ## Connect from the Auto Scaling Group On the Auto Scaling Group's details page, the **Associated Load Balancers** tab has the project's web Load Balancers. A Load Balancer that is **Initializing** or **Failed** is listed only when the group is already attached to it. 1. In the row of the Load Balancer, open the menu and select **Attach**. 2. Under **Backend group**, check the name, **Protocol** and **Port**. The backend group is named after the group with "-backend" added. Choose HTTP, the default, HTTPS or gRPC. **Port** starts at 80; set it to the port your application listens on. 3. Check the **Routing rule** section. The rule is named after the group with "-route" added. It matches every request, so it sends 100% of requests to the new backend group. 4. (Optional) Open **Advanced settings** to set **Distribute requests by**, the health check, **Request timeout (s)** and **Retry attempts**. 5. Select **Attach**. The group is now behind the Load Balancer. Both names are required, the backend group name must be new on that Load Balancer, and the port must be valid. If the Load Balancer already has a rule that matches every request, the first matching rule wins, so add a condition to the new rule. If the backend group is created but the rule is refused, traffic has yet to reach the group. Detach the group and try again once the Load Balancer is healthy. To start from the group instead, select **Create Load Balancer** on the same tab. The new Load Balancer starts with the group as a backend. ## Check that traffic reaches the group **Traffic to this group** says whether the Load Balancer is serving the group. **Not routed** means the Load Balancer is Running and still needs an active rule that forwards to the group's backend group. Add a rule that forwards to it. ## Detach the group Detach an Auto Scaling Group to stop the Load Balancer sending traffic to it. In the row of the Load Balancer, open the menu, select **Detach**, and confirm. The group's VMs stop receiving traffic from the Load Balancer immediately. They keep running, and you can attach them again. Detaching removes the group from every backend group of that Load Balancer: - A backend group that held only this Auto Scaling Group is deleted, and so is a rule that forwarded only to it. - A rule that also forwards to other backend groups only loses this destination. Before you confirm, the dialog names the backend groups that will be removed along with their routes. When the detach would remove the Load Balancer's only rule, the dialog also warns that the Load Balancer will then answer 503 to every request. To make the same connection from the group's side, see [Connect a load balancer](/tir/tir-auto-scaling/how-to/connect-a-load-balancer/). To control which traffic can reach the Load Balancer next, see [Manage security groups](/tir/tir-load-balancer/how-to/manage-security-groups/).