Creating a Mini Project (Ecommerce web application ) using EC2 , Elastic Load Balancer (ELB).
Overview
Create a highly available and scalable web application using Elastic Load Balancer(ELB).
Introduction
One of the advantages of working with the cloud is autoscaling, which automatically changes your infrastructure and resources to meet the current level of demand. Another advantage is load balancing which is needed to help control and regulate the traffic demanding your resources. Having a web application with these features makes room for optimal performance and efficiency so walk with me let's create one together.
AWS Ec2 Instance for Web Application
AWS EC2 (Elastic Compute Cloud) is a service that provides scalable and reliable computing resources for web applications.
Prerequisite
An AWS account
Basic knowledge of VPC and subnet
Script for the web application
👉Step 1: Create your Servers using AWS EC2 service
i. Use the search bar to search for Ec2 and click on it.
ii. Create 2 servers for the two subnets you created by clicking on launch instance
iii. Set the name of your first server and leave everything after as default until you get to network settings where you select the VPC you created and select one subnet out of the two you created.
iv. After network settings set your security group inbound details to SSH from anywhere and HTTP from anywhere because we are working with a public subnet
v. Leave everything after the security group as default and once you get to Advanced details select it and scroll down to user data, this is where you input the script for your web application and then click on launch instance.
vi. Install in server Apache2 and check into browser it . command is.
vii. Go to CMD and go their where your code is present , like in D drive or Download section anywhere it is.
and check your on server ..
viii. Install unzip and extract your zip file .
ix. Go to that directory where apache2 main file is running and remove it then replace it your code of main file .
Go to browser check it your web application is running .
Your E-commerce website application is running on Apache .
👉Step 2: Set up your Elastic Load Balancer
i. Use the search bar to search for Load balancer and click on it Or Search Ec2, click on it and the left panel of services under Ec2 Scroll down to load balancers
ii. Click on create the load balancer
iii. We are working on a web application so select the application load balancer and click on create
iv. Input the name of the load balancer, It is for internet users so leave the scheme as internet facing and leave the IP address as default
v. Under the network mapping, select the VPC you created then under availability zones select both.
vi. Create a new security group, select the VPC you created and for the inbound rules add HTTP from anywhere. Leave every other thing as default and click on Create a security group.
vii. Go back to set up and at security group select the security group you just created
viii. Under listening and routing, for listening select HTTP as protocol and Port 80. Then create a target group for where the traffic will be channeled to
ix. After clicking Create target group select the instance and leave other details as default and HTTP where applicable
x. Click on next then select instances created to register them as target
xiii. Go back to setting up the load balancer and select the target group you just created
xiv. Scroll down and Click on Create the load Balancer to complete the set-up
xv. To test your load balancer, scroll down copy the DNS and paste it into another tab. After it opens refresh to see if it connects you to another server. Then you know that your load balancer has been set up properly.
xvi. Paste the link in a new tab and click enter. The details of the first instance will appear.
Conclusion
In conclusion, Load Balancing are important concepts that every cloud/DevOps Engineer or individual learning cloud computing needs to know due to the value they bring to any Cloud project.
Load balancing helps to navigate, control and balance the traffic coming into an infrastructure to ensure smooth flow. From the explanation, it is a must-know and should be applied while creating your infrastructure so the steps highlighted above should be carefully followed when implementing load balancing.