Showing posts with label load. Show all posts
Showing posts with label load. Show all posts

Thursday, 1 October 2020

Application load balancer

with  Application load balancer can do the following:

  • Load balancing to multiple HTTP applications across machines (target groups)
  • Load balancing to multiple applications on the same machine(ex: containers)
  • Load balancer based on route in URL.
  • Load balancer based on hostname in URL.
in comparison, we would need to create one Classic load balancer per application before. That was very expensive and inefficient.



Target group represent one application included with some EC2 instances along with health check. we will register the target group to Application load balancer.

in the below flowchart, we have 2 target group with representation of 2 application, registered to application load balancer with the protocol HTTP.


if the user searches for route/user, then the application load balancer redirected it to target group users. Similarly for search target group also,if the user search for route/search, our Application load balancer will re-direct it to search target group.




in this post, we will do hands on for:

  • Create a target group.
  • Setup an application load balancer.
practical steps for Create a target group :

---------------------------------------------------------------------------------------------------------------------------
from load balancer page --> Navigate to load balancer --> target groups(as shown below).




Click on Create target group.


Provide details:
1. enter target group name:                                                                           
2.enterprotocol for EC2 instance connection from target group.         
3.port no. for HTTP protocol is 4567.                                         
4.VPC: i'm give default one.                                                

Health check settings:                                                                                           
protocol as HTTP                                                                            
path = /health                                                                                  

Click on the Advanced health check settings dropdown.                                                                              provide the override port (ex: port no.4568) if required.                                                    
provide time interval info.                                                                                                 
finally click on create. 

conformation screen for target group creation.                                                                                                  





Then screen will prompts to target group page, Navigate to Targets tab --> Edit.

Then the screen goes to Register and deregister targets page. 
1.Ensure that the port number is 4567 based on protocol.                                          
2.select the required EC2 instance that need to add target group.                              
                 3.click on Add to registered.                                                                                                      4.Finally click on SAVE option available at the right bottom of the page.               
                                    


Now both the EC2 instances are available now in the targets group tab. but the status of EC2 instance will be unused until load balancer assigned to target group.



-----------------------------------------------------------------------------------------------------------------------------

  • practical steps for Setup an application load balancer:


Now navigate to load balancer page:


Click on create load balancer.



Choose application load balancer--> Click on Create.


provide details for the load balancer:

Name : <load balancer name>
scheme: internet facing - public ip based load balancer( web)
by default load balancer HTTP protocol and load balancer port as 80 is available.



here i am selecting all the availability zones and click on Next.


can add other protocol waring screen will appears in the next step. can ignore and click on next.
if any other protocol is required add them in the last step & Now click on Next.




Add security Groups to the load balancer.


Configure routing: 

choose Target group as Existing target group.
Name : dropdown select the correct load balancer.

rest all information will be updated based on this 2 entries.

Click on Next.



Conform the target groups and click on Next.


Review all the inputs and click on create.




Now change security groups, so that application load balancer will access the EC2 instances.







That's all similarly we can add multiple target groups to single Application load balancer.



-----------------------------------------------------------------------------------------------------------------------------

Sunday, 27 September 2020

Classic load balancer

 Even though it is old version of load balancer many AWS users are still using these one.


From EC2 instance launch page, Navigate to load balancer option.




Click on Create Load Balancer.

Click on create for Classic load balancer

 

Then the below screen will prompts.
Provide details:

from the below screen shot:

1.Load Balancer name: <just description for the load balancer>
2. Provide VPC details: here i am selecting default VPC.
3. Create an internal load balancer - if the check box is enable the load balancer will work for the private network. Vice versa disable the check box to make load balancer for public network.  
4.Enable advanced VPC configuration: is to configure load balance for subnet VPC.
5. Add button: To enable ports for new protocol.
6.Portion 6 in the below screen: for load balancer protocol and respective port number.
7. Portion 7 in the below screen: is protocol and port number of EC2 instance.

Assign security groups:

1. in between Create a new security group and select an existing security group options, select based on you own requirement.

if No security group are available, select create a new security group option.

2.provide security group name and description for the security group.
3.provide protocol info, by clicking on the Add rule button.

Click on Next 



3. Configure security settings: improve your load balancer's security, by using either HTTPS or the SSL protocol for your front-end connection.



Configure Health Check: 

your load balancer will automatically perform health checks on your EC2 instances and only route traffic to instances that pass the health check. if an instance fails the health check, it is automatically removed from the load balancer. customize the health check to meet your specific needs.



Add EC2 instances:

The table below lists all your running EC2 instances. Check the boxes in the select column to add those instances to this load balancer. 

1. Select the required EC2 instance for load balancing to load balancer.

2.Enable cross Zone load balancing: if the EC2 instances are available in 2 Availability zone, then need to enable this check box.

Enable connection Draining: connection health check for the EC2 instances,  if the EC2 instance is not connect to load balancer with in 300 seconds. then the load balancer will treat EC2 is unhealthy.

Finally check on Next.


Add tags:

tags are used for better description of EC2 instances.
Add tags based on your own requirements.

Here i'm not adding any tags. Click on Next.

Review:

review all the parameters provided for the creation of load balancer so far. Finally Click on Create.



Conformation screen looks like below, Click on the load balancer name as shown below. 
DNS name can obtain here: with this DNS name can access application.





Copy the DNS name and paste in browser to check load balancing

Friday, 25 September 2020

introduction to load balancer

 Load balancers are basically servers that forward internet traffic to multiple servers (EC2 instances) down stream.


suppose we have 3 EC2 instances and all the 3 runs same application and  one load balancer.


       


             Similarly if we have 1500 users load balancer will assign 500 user to first EC2 instance,500 users to second EC2 instance and 500 users to third EC2 instance.


Why to use a load balancer?

  • Spread load across multiple downstream instances.
  • Expose  a single point of access (DNS) to your application.
  • Seamlessly handle failures of downstream instances.
  • Do regular health checks to your instances.
  • Provide SSL termination (HTTPS) for your websites.
Types of load balancer on AWS:
  1. Classic Load balancer(V1).
  2. Application load balancer(V2 - new generation).
  3.  Network load balancer(V2 - newer generation).

    it is recommended to use the new the newer / v2 generation load balancers as they provide more features.
You can setup internal (private) or external (public ) ELBs


internal(private): load balancer for applications with in private network.

external( public): load balancer for applications in the public network.
                             ex: web server.


Friday, 31 July 2020

How to configure email alert in AWS for EC2 instance, if CPU load is above 90%


If cpu utilisation is above 90%. then the below configuration will trigger an email notification conveying the same.


Practical steps:                                                                                                                                                       

1. Login to AWS console.                                                                                                                 
2.Ensure that your in correct require DC.                                                                                         
3.Navigate to Services --> under Management & Governance -->Cloudwatch as shown below.


4. Then the below display will display.                                                                                                 


5.Click on Alarms now.                                                                                                                                


6. Click on Create Alarm as shown below.                                                                                                              

7.Now click on select metric as shown below.                                                                                       


8.Click on EC2 as shown below.                                                                                                                   


9. Click on Per-instance Metrices.                                                                                                                   

10. In the new browser tab collect the EC2 instance id info from  running instance page(Services -->EC2-->Running instance -->collect the instance id number for correct EC2 instance for which CPU mail alert is required.

11. Based on the instance id number from the above step & CPU utilization from Metric Name column, select the correct entry, by select the check box as shown below.

12.Enter Alarm details:                                                                                                                                     Name & Description are free text, generally used for better identification among other alarms.   
is >= 90      is the actually value that will trigger the mail. 
1 minute out of 1minute, if the CPU utilization is above 90% for 1 minute out of 1 minute then mail will trigger.

eg: can use 5 minutes out of 3 minutes.
                  10 minutes out of 5 minutes.


13.Enter the recipient mail id by clicking on the New list option as shown below.                                                                       


14.Enter the Alarm description again here in the below highlighted field & click on create                       alarm option available at the right side bottom of the screen.                                                          


15.Then screen prompt for the mail confirmation screen. Open receipt mail id, inbox and conform the acknowledge the AWS alerts.


16.By click on the conformation link in the mail. screen similar like below will appears.                                   

17. Click on View Alert now.                                                                                                                        

18. Optional steps: To check the functionality of Alert. open the putty session for the EC2 instance and execute the lines while true; do echo; done;
so that CPU utilization reached to 90% with in short time.

To open the putty session for EC2 instance:                                                                                                  how to establish putty connection to AWS EC2 instance using AWS console      



19. Hurrah!!! It working.