Working-up with Application Load Balancer
So, now our scenario is distributing traffic based on our URL path, currently we 2 instance which one has homepage of our website and 3 instance which only has products page of the website
We want is whenever traffic comes for products page it should be served through 3 products instance
- For doing this we will use ALB, but first we need to create Target groups for ALB
Go to EC2 Dashbroad and scroll to Target Groups > Create target group
- Input the Target group name and path
- Scroll down and select Advanced health check settings as shown below
- Once target group created select it > Actions > Register and deregister targets
- Select Home-EC2 > Add to registered > Save
- Similarly created target group and register Products-EC2 to it
- Once Home and Product target group is created, create ALB
- Input the Name
- Scroll down and select all Availability Zones, this basically allows ALB to server traffic to instance in any 6 AZs
- Select default security group
- Select Existing target group and select Home target group previously created
- Now select your ALB and go to Listeners tab then click on View/edit rules
- Click + button > Insert Rule
- Select Path is… > give path as */products/* then Forward to… to Products target group > Save
- Now try to open ALB DNS in browser it should open This is our Homepage page
- Now if you open <LB-DNS>/products/products.html it will open This is our products page page
This is getting served through our 3 products instances