Add endpoint groups to the accelerator

The new requirement is to make sure your web application is deployed in at least two different AWS regions, different reasons can explain this requirement:

  • compliance
  • latency
  • blue/green deployments,
  • A/B testing,
  • failover in case for example something happens to the Lambda function,
  • handle increased traffic,
  • etc.
  1. Launch the CloudFormation you used in the Workshop Initialization in two different regions of your choice, do not launch in the region you previously used. I choose EU-WEST-1 (Dublin) and AP-NORTHEAST-1 (Tokyo) Regions, and AGAWorkshop as the stack name in each region, wait for the stack to be completely created (it takes about 3 minutes).
  2. Open the Amazon Global Accelerator console.
  3. Choose your accelerator (AGAWorkshop by default).
  4. Under Listeners, click on your listener.
  5. On the listener page, click on Add endpoint group.
  6. Select the region in the dropdown menu, enter 0 for Traffic dial, then click on Next
  7. As for the previous lab, add the new endpoint to the endpoint group
    • Endpoint Type: Application Load Balancer
    • Endpoint: [Choose the new ALB created via CloudFormation] - The list will auto-populate for you
    • Weight: 128
    • Keep Preserve client IP address checked
  8. Click on Save
  9. Repeat steps 1 to 8 to add the other endpoint group

Make sure you choose the right regions for the two new endpoint groups, otherwise you won’t see the new ALBs in the dropdown menu.

Your listener page should look like the following: x

This is my architecture

x

Verify that the new endpoints do not serve traffic

  1. Via cURL
$ for i in {1..100}; do curl http://aebd116200e8c28ad.awsglobalaccelerator.com/ --silent >> output.txt; done; cat output.txt | sort | uniq -c ; rm output.txt;
  51 Processed in US-WEST-2 by AGAWorkshop-Function-P5UKYRRL0N05
  49 Processed in US-WEST-2 by AGAWorkshop2-Function-5N9U2S8PPDFP
  1. Via a browser (refresh the page to see what happens) x

  2. If you are at an AWS Event, use the web page the instructor shared with you x

To make sure your new load balancers are well configured and can handle traffic, send only a portion of the traffic to them, lets change the traffic dials for the two endpoint groups from 0% to 10%, keep the traffic dial of the initial endpoint group to 100%. By doing so, the new endpoints will handle 10% of the traffic they are supposed to handle.

Traffic dials vs Endpoint weights: AWS Global Accelerator relies on the traffic dials to control the percentage of traffic that is directed to an endpoint group, and on endpoint weights to determine the proportion of traffic that is directed to endpoints in an endpoint group. Depending on your use-case, you can use the former, the latter, or a combination of both. For more information, see the documentation

  1. Open the Amazon Global Accelerator console.
  2. Choose your accelerator (AGAWorkshop by default).
  3. Under Listeners, click on your listener.
  4. On the listener page, select the first endpoint group (do not click on) that has 0% as traffic dial and click on Edit.
  5. Change the traffic dial from 0 to 10
  6. Click on Save changes
  7. Select the other endpoint group that has 0% as traffic dial and click on Edit.
  8. Change the traffic dial from 0 to 10
  9. Click on Save changes

x

Verify that the new endpoints serve some traffic

  1. Via cURL (from a client located in Cape Town, South Africa)
$ for i in {1..100}; do curl http://aebd116200e8c28ad.awsglobalaccelerator.com/ --silent >> output.txt; done; cat output.txt | sort | uniq -c ; rm output.txt;
  11 Processed in EU-WEST-1 by AGAWorkshop-Function-1DSF709GD6VSZ
  41 Processed in US-WEST-2 by AGAWorkshop-Function-P5UKYRRL0N05
  48 Processed in US-WEST-2 by AGAWorkshop2-Function-5N9U2S8PPDFP
  1. Via cURL (from a client located in Mumbai, India)
$ for i in {1..100}; do curl http://aebd116200e8c28ad.awsglobalaccelerator.com/ --silent >> output.txt; done; cat output.txt | sort | uniq -c ; rm output.txt;
  12 Processed in AP-NORTHEAST-1 by AGAWorkshop-Function-1VSQ5IKCPZ608
  10 Processed in EU-WEST-1 by AGAWorkshop-Function-1DSF709GD6VSZ
  37 Processed in US-WEST-2 by AGAWorkshop-Function-P5UKYRRL0N05
  40 Processed in US-WEST-2 by AGAWorkshop2-Function-5N9U2S8PPDFP
  1. If you are at an AWS Event, use the web page the instructor shared with you x

From what we can see on this sample:

  • 3 endpoints served clients from Cape Town (EU-WEST-1 is the region that should have served all the traffic if it traffic dial was 100%)
  • 4 endpoints served clients from Mumbai (AP-NORTHEAST-1 or EU-WEST-1 should normally serve all Mumbai traffic, and the other the rest of the traffic. Since their traffic dials are not 100%, a 3rd region served the rest of the traffic)
  • 2 endpoints served clients from Ohio (US-WEST-2 would normally serves Ohio, since it traffic dial is 100%, it served all the Ohio)
  • 4 endpoints served clients from Singapore (same comment as for Mumbai)
  • 3 endpoints served clients from Paris (same comment as for Cape Town)
  • 2 endpoints served clients from Sao Paolo (same comment as for Ohio)
Learn more... How does this work behind the scenes?

Discuss your results with the instructor. Play with traffic dials to see how AWS Global Accelerator routes requests to endpoint groups based on the user locations. Set the traffic dials of each endpoint group to 50% and discuss the results with the workshop instructor.

Since everything seems to be working as expected with the new endpoints, let’s increase the new endpoint group traffic dials from 10% to 100%, and see how AWS Global Accelerator routes requests.

x

  1. Via cURL (from a client located in Cape Town, South Africa)
$ for i in {1..100}; do curl http://aebd116200e8c28ad.awsglobalaccelerator.com/ --silent >> output.txt; done; cat output.txt | sort | uniq -c ; rm output.txt;
  100 Processed in EU-WEST-1 by AGAWorkshop-Function-1DSF709GD6VSZ
  1. Via cURL (from a client located in Mumbai, India)
$ for i in {1..100}; do curl http://aebd116200e8c28ad.awsglobalaccelerator.com/ --silent >> output.txt; done; cat output.txt | sort | uniq -c ; rm output.txt;
  100 Processed in EU-WEST-1 by AGAWorkshop-Function-1DSF709GD6VSZ
  1. If you are at an AWS Event, use the web page the instructor shared with you x

CHECKPOINT: You just implemented a multi-region application with AWS Global Accelerator, it uses traffic dials to control the percentage of traffic that is directed to an endpoint group. This implementation can help for compliance, performance, blue/green deployments, A/B testing, failover in case for example something happens a Lambda function, handle increased traffic, etc. Ready for the next challenge?


CHALLENGE 4: You just added a feature to your application that saves data about each client session and uses it the next time the client makes a request, in other words your application is now stateful. How would you implement this - Move to the next lab when you are ready!