Step 4 – Configuring load balancer (ELB)
For this step, you will create and configure a load balancer using the Elastic Load Balance (ELB) service. ELB is a service that automatically distributes incoming traffic between multiple ECS to balance their loads. In our case, the load distributor we are going to create will improve fault tolerance and expand the service capabilities of the applications installed on our web server.
To create an ELB, click Elastic Load Balance, and then Create Elastic Load Balancer.
On the new page that appears, enter the following information:
- Type: Public network
- Subnet: Web-subnet
- VPC: web-vpc
- EIP: use Existing (select the EIP from the previous)
- Description: load distributor for the web server
- Name: elb-advanced
Click Create Now, then on Submit, and wait for a few seconds for the screen to show the newly created ELB.
Now, we have to specify the protocols that we want to do with the load distribution. For this, we create two Listeners object associated with our ELB. Select the newly created load balancer (elb-advanced), and click the Add Listener button and fill in the following information:
Listener 1
- Name: listener-advanced
- Frontend Protocol/Port: HTTP/80
- Backend name : server-advanced
- Backend Protocol/Port: HTTP/80
- LB Mode: Weighted round robin
- Sticky Session: No
- Enable Health Check : Yes
- HealthCheck Mode: HTTP/80
- Interval (s): 5
- Timeout (s): 10
- Maximum Retries: 3
Listener 2
- Name: listener-advanced-ssh
- Frontend Protocol/Port: TCP/22
- Backend name : server-advanced-ssh
- Backend Protocol/Port: TCP/22
- LB Mode: Round Robin
- Sticky Session: Yes
- Stickiness Duration: 5 min
- Enable Health Check : Yes
- HealthCheck Mode: TCP/22
- Interval (s): 5
- Timeout (s): 10
- Maximum Retries: 3
Click OK.
Then go to Backend Server Groups and add the ecs with the correct port: in server-advanced add ecs-web by putting as port 80 and in server-advanced-ssh add ecs-web by putting as port 22
You can now access the web site via the ELB, specifying in your web browser the ELB’s EIP in place of that of the ECS : http://<EIP de ELB>/index.html.