A load balancer gives your Auto Scaling Group one address and shares the requests among its VMs. TIR Load Balancer covers the load balancer itself. To make the same connection from the load balancer’s side, see Connect an Auto Scaling Group.
Before you begin
Section titled “Before you begin”- An Auto Scaling Group in your project. See Create an Auto Scaling Group.
- A load balancer of the type Web traffic (HTTP/HTTPS) that is Running or Stopped. You can make one from the group; see Make a load balancer for the group. To make one separately, see Create a Load Balancer.
- Update permission on the Load Balancer service to attach and detach, and create permission to make a new load balancer. See TIR Access Control.
- The port your application listens on. The VMs must answer on it.
Make a load balancer for the group
Section titled “Make a load balancer for the group”On the Associated Load Balancers tab of the group, select Create Load Balancer. The new load balancer starts with this group as its backend.
Attach the group to a load balancer
Section titled “Attach the group to a load balancer”- On the details page of the group, open the Associated Load Balancers tab, which has every Web traffic load balancer the group can use.
- Open the row menu of the load balancer and select Attach.
- Under Backend group, check the Name, Protocol and Port. TIR suggests
<group name>-backendas the name, adding -2, -3 and so on if the load balancer already uses it. Choose HTTP, HTTPS, or gRPC, and set Port to the port your application listens on. - Under Routing rule, check the Rule name,
<group name>-routeby default, and When a request matches. A rule with no condition sends every request to the group. - (Optional) Under Advanced settings, change how requests are distributed, the health check, the request timeout, and the number of retries.
- Select Attach.
If the load balancer already has a rule with no condition, this group would receive nothing, so add a condition to the new rule before you attach.
Attaching creates a backend group and a routing rule. If the load balancer refuses the rule, the group is added but no traffic reaches it yet; detach, and attach again once the load balancer is healthy.
Attach from the load balancer
Section titled “Attach from the load balancer”On the load balancer’s own create or edit page, the backend picker lists an Auto Scaling Group under the tab Auto Scaling Group. You can pick a group only while it is Running. This attaches the group itself, not a snapshot of its VMs. An Auto Scaling Group needs a backend group of its own that holds only the group.
Check which load balancers serve the group
Section titled “Check which load balancers serve the group”On Associated Load Balancers, Traffic to this group says whether requests reach the group. Serving means they do. Otherwise it says why not: the route is missing and the load balancer answers 503, the group has no VMs to serve, or the load balancer has failed, is stopped, is starting or is unavailable. Domain is the load balancer’s address, once it has one. An attached load balancer stays listed even while it is Initializing or Failed. If there is none to attach, create one from the same tab.
Once traffic reaches the group, Connect on Overview gives the load balancer’s address as
https://<domain>.
Detach the group
Section titled “Detach the group”- On the Associated Load Balancers tab, open the row menu of the attached load balancer and select Detach.
- Confirm. The group’s VMs stop receiving traffic from the load balancer and keep running, and you can attach the group again at any time.
Detaching also removes the backend group and its route when this group was its only member. If that was the load balancer’s only routing rule, it then answers 503 to every request.
Check that traffic reaches the group
Section titled “Check that traffic reaches the group”Traffic to this group reads Serving for the load balancer, and the Domain opens your application. Requests are shared among the VMs that the group has running.
To see which VMs receive traffic, see Monitor an Auto Scaling Group. For help with a group that returns 503, see Troubleshooting TIR Auto Scaling Groups.