Featured resource
2025 Tech Upskilling Playbook
Tech Upskilling Playbook

Build future-ready tech teams and hit key business milestones with seven proven plays from industry leaders.

Check it out
  • Lab
    • Libraries: If you want this lab, consider one of these libraries.
    • Cloud
Google Cloud Platform icon
Labs

Use Application Load Balancers for Web Servers

Load balancing automatically distributes your incoming traffic across multiple targets, such as EC2 instances, containers, and IP addresses, in one or more Availability Zones. In this lab, we configure an Application Load Balancer to distribute network traffic to two EC2 instances. We then enable stickiness, so that once a server is contacted, the user is always sent to that server. This ensures our legacy application continues to work despite not supporting distributed logins. By the end of this lab, the user will understand how to create an Application Load Balancer and enable sticky sessions.

Google Cloud Platform icon
Lab platform
Lab Info
Level
Beginner
Last updated
Sep 24, 2025
Duration
1h 0m

Contact sales

By filling out this form and clicking submit, you acknowledge our privacy policy.
Table of Contents
  1. Challenge

    Observe the Provided EC2 Website and Create a Second Server

    NOTE: While we generally recommend folloiwng the steps in the lab as shown, if you have trouble with using any of the public IPs referrenced in the lab, you can try using the public DNS name instead (Please be aware that DNS propogation delays are possible with this approach).

    Observe the website configured on the existing EC2 server. Using the bootstrap script provided, boot another EC2 server.

    For your new EC2 use the following settings:

    1. For your AMI, use Ubuntu Server 22.04 LTS.

      Note: If you get a popup window that tells you some of your current settings will be changed, click on Confirm changes.

    2. Under Network settings, enable the option to Auto-assign Public IP.
    3. For the security groups, select the one with EC2SecurityGroup in its name (not the default security group).
    4. Add the following bootstrap script:
        #!/bin/bash
        
        # Update and install necessary packages
        sudo apt-get update -y
        sudo apt-get install -y apache2 unzip
        
        # Fetching the token for IMDSv2
        TOKEN=`curl -X PUT "http://169.254.169.254/latest/api/token" -H "X-aws-ec2-metadata-token-ttl-seconds: 21600"`
        
        # Starting HTML file
        echo '<html><center><body bgcolor="black" text="#39ff14" style="font-family: Arial"><h1>Load Balancer Demo</h1><h3>Availability Zone: ' > /var/www/html/index.html
        
        # Using the token to fetch metadata
        echo $(curl -H "X-aws-ec2-metadata-token: $TOKEN" http://169.254.169.254/latest/meta-data/placement/availability-zone) >> /var/www/html/index.html
        echo '</h3> <h3>Instance Id: ' >> /var/www/html/index.html
        echo $(curl -H "X-aws-ec2-metadata-token: $TOKEN" http://169.254.169.254/latest/meta-data/instance-id) >> /var/www/html/index.html
        echo '</h3> <h3>Public IP: ' >> /var/www/html/index.html
        echo $(curl -H "X-aws-ec2-metadata-token: $TOKEN" http://169.254.169.254/latest/meta-data/public-ipv4) >> /var/www/html/index.html
        echo '</h3> <h3>Local IP: ' >> /var/www/html/index.html
        echo $(curl -H "X-aws-ec2-metadata-token: $TOKEN" http://169.254.169.254/latest/meta-data/local-ipv4) >> /var/www/html/index.html
        
        # Ending HTML file
        echo '</h3></html> ' >> /var/www/html/index.html
        
        # - Ensure the Apache2 service is enabled and started.
        sudo systemctl enable apache2
        sudo systemctl start apache2
    
    
  2. Challenge

    Create an Application Load Balancer

    Create a load balancer called LegacyALB with a target group called TargetGroup, add the two EC2 servers as targets, and observe how the load balancing works in your web browser.

  3. Challenge

    Enable Sticky Sessions

    Configure the load balancer to use stickiness, and observe how the load balancer now only directs the user to a single EC2 server (as expected).

About the author

Pluralsight Skills gives leaders confidence they have the skills needed to execute technology strategy. Technology teams can benchmark expertise across roles, speed up release cycles and build reliable, secure products. By leveraging our expert content, skill assessments and one-of-a-kind analytics, keep up with the pace of change, put the right people on the right projects and boost productivity. It's the most effective path to developing tech skills at scale.

Real skill practice before real-world application

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Learn by doing

Engage hands-on with the tools and technologies you’re learning. You pick the skill, we provide the credentials and environment.

Follow your guide

All labs have detailed instructions and objectives, guiding you through the learning process and ensuring you understand every step.

Turn time into mastery

On average, you retain 75% more of your learning if you take time to practice. Hands-on labs set you up for success to make those skills stick.

Get started with Pluralsight