Application Load Balancer without stickiness - AWS Prescriptive Guidance

Application Load Balancer without stickiness

When you use an Application Load Balancer without any form of stickiness, by default, the load balancer uses the round robin method to determine the EC2 instance it should route traffic to.

Template: Use the AWS CloudFormation template basic.yml (included in the sample code .zip file) to try out this functionality.

Note

All CloudFormation templates included with this guide deploy a custom VPC, route tables, routes, an internet gateway, an Application Load Balancer, target groups, listeners, and EC2 instances, to illustrate a specific load balancer stickiness strategy.

Common use cases

Use an Application Load Balancer without stickiness in these scenarios:

  • You have a list of targets to route traffic to, but the targets do not maintain session state.

  • You’re using web servers that do not maintain session state.

  • You’re using application servers that do not maintain session state.

Steps

Notes
  • NAT gateways incur a small cost.

  • Multiple EC2 instances use up your free tier hours faster than a single EC2 instance.

  1. Deploy the CloudFormation template basic.yml in a lab environment.

  2. Wait until the health status of your target group instances changes from initial to healthy.

  3. Navigate to the Application Load Balancer URL in a web browser, using HTTP (TCP/80).

    For example: http://alb-123456789.us-east-1.elb.amazonaws.com/

    The webpage displays Instance 1 - TG1 or Instance 2 - TG1.

  4. Refresh the page multiple times.

Expected results

The instance that loads the web page (Instance 1 or Instance 2) should change every time, as reflected in the page text. The load balancer logic manages the last target across multiple internal nodes, which may introduce a synchronization delay, so there’s a possibility that you will be routed to the same target.

How it works

  • In this example, two EC2 instances are assigned to a single target group. The EC2 instances have an Apache web server (httpd) installed, and the index.html page text on each EC2 instance is hardcoded to identify that instance.

  • The Application Load Balancer runs its internal round robin logic to determine which EC2 instance should receive the traffic.

  • Each time you reload the web page, the Application Load Balancer runs its routing logic, and the page displays Instance 1 - TG1 or Instance 2 - TG1.