18.2 How many EC2 instances
Why the count is your choice
Students see one DNS name and think there is one computer. There is not. The load balancer is not your EC2. It does not run your Nginx, your PHP, or your files. Your EC2 instances do that. You choose how many of those instances are registered. One is enough for the balancer to return a page. One is not enough when that instance stops. This lab uses two so you can stop one and still get a page.
What the numbers mean
| Number | Meaning in this chapter |
|---|---|
| The load balancer | Not an EC2. You do not SSH to it and install Nginx |
| Minimum that still answers | 1 healthy target |
| This lab | 2 EC2 instances, both registered |
| Chapter 17 Auto Scaling group | Minimum 1, and the lab there used desired 1 then 2, maximum 3. The group can change the count. The balancer does not pick a number by itself |
If zero targets are healthy, the user does not get your page. An Application Load Balancer then answers with 502 Bad Gateway. The DNS name still exists. The front door is up. The rooms behind it are empty.
How to count them before you build the balancer
- Open the EC2 console.
- Count the running instances you will put behind the balancer.
- Write that count. For this lab, write 2.
- Confirm neither of those two is the load balancer. The load balancer is not in the instance list.
- You should see two running instances, and no row named "load balancer" in that instance list.
Later, when the Auto Scaling group changes desired capacity, come back to this count. The target group list grows or shrinks. The load balancer's own name stays one name.