Wednesday 30 September 2020

How to route all traffic to one particular EC2 instance out of 2 EC2 instance in load balancer

 Suppose in one of the EC2 instance out 2 EC2 instance of load balancer need to perform maintenance activity. Then all the traffic need to forward to other EC2 instance.

Practical steps:

Step 1: from the load balancer page -->  instances tab --> check the status.


Step 2: Ensure that ping path in the health check is /health.

for that Navigate to Health check tab & go with option click on Edit Health Check option.



Ensure below details:


Ping protocol: HTTP

ping port : 4567

ping path = /health

Advanced Details:


timeout time for 5 seconds

interval for health check to be performed

unhealthy threshold = 2 ( if twice the health check is unhealth, then the system status will be unhealth)

healthy threshold =5 if the health check result is healthy for last 5 checks, then system is healthy as per the health checks.



Step 3:                                                                                                                                                           

For some maintenance activity, to make EC2 instance status as Not health follow below link in the browser.


DNS link/health/flip

Then the result will be Not healthy as shown below:


Step 4:                                                                                                                                                                           
Then move back to link: DNS link/health (as shown below), it will still display status as health. Because of another health EC2 instance and if you refresh it again Not healthy from unhealthy EC2 instance. Meaning load balancing is still working.                                                                                     




Step 5:                                                                                                                                                                       
After some refresh time. the status in instances tab will changes to Outofservice.  Because  of step3 process.



Step 6:

perform all the maintenance activities that need perform on unhealthy EC2 instance.


 
Step 7: Make the EC2 instance back to healthy( in service) status.

Now using public ip with port 4567 make it healthy again.

<public_ip>:4567/health/flip




Step 8:                                                                                                                                                            
As for the health check rules.for every 10 sec and 5 times of check (i.e., 50 sec) the status of EC2 will changes back to in service again.


step9:conformation screen.                                                                                                                                             












No comments:

Post a Comment