DEV Community

Morodolu Oluwafikunayomi
Morodolu Oluwafikunayomi

Posted on

Load Balancing in AWS: Deliver High Availability with Smart Traffic Distribution

In today's cloud-native world, users expect applications to be fast, reliable, and always available. Whether it's a web app, an API, or a containerized service, your infrastructure needs to be able to handle changing traffic loads without breaking under pressure.
That’s where load balancing comes in — and in AWS, Amazon Web Services (AWS), Elastic Load Balancing (ELB) is a fully managed service designed to automatically distribute incoming traffic across multiple targets such as EC2 instances, containers, and IP addresses.

What is Load Balancing?
Load balancing is the process of distributing incoming network traffic across multiple backend resources. This prevents any single resource from becoming a bottleneck, thereby improving:

  • Availability
  • Scalability
  • Fault tolerance
  • Performance
    Types of Load Balancers in AWS
    AWS offers four types of load balancers under the Elastic Load Balancing (ELB) service:
    But before that there is something called OSI model( Open Systems Interconnection model), it is a conceptual framework that standardizes how computer systems communicate over a network, it operates at a seven layer framework, which are

  • physical

  • datalink

  • network

  • transport

  • session

  • presentation

  • application
    Depending on what your app needs, AWS offers four types of load balancers. Here's a quick overview and which layer they operate at:

  • Application Load Balancer (ALB)

  • Operates at Layer 7 (Application)(HTTP/HTTPS).

  • Great for routing based on content (like path or hostname).

  • Perfect for modern web apps and microservices.

  • Network Load Balancer (NLB)

  • Works at Layer 4(transport)(TCP/UDP).

  • Designed for ultra-low latency and high throughput.

  • Ideal for high-performance, real-time applications.

  • Gateway Load Balancer (GWLB)

  • Best suited for integrating third-party security appliances like firewalls or intrusion detection systems.

  • Routes traffic transparently while scaling with demand.

  • Classic Load Balancer (CLB)

  • Older generation, supports both Layer 4 and Layer 7.

  • Mostly used in legacy systems, not recommended for new projects.

How Load Balancing Works in AWS
Here’s a simplified view of what happens when someone accesses your app through a load balancer:

  • A user makes a request to your application (e.g., opens your website).
  • The request is sent to your load balancer via a DNS name.
  • The load balancer checks which backend servers (targets) are healthy.
  • It forwards the request to one of those healthy servers based on a routing algorithm (like round-robin).
  • The chosen server processes the request and sends the response back through the load balancer to the user.

Simple, seamless, and scalable.

_in simpler terms _
When one server is receiving too much traffic, instead of letting it get overwhelmed, the load balancer steps in and says:

“Hey, this server is getting busy — let me send the next request to another server that’s less busy or idle.”

  • it distributes incoming traffic across multiple servers, which:
  • Prevents any one server from crashing or slowing down
  • Keeps your app fast and available
  • Helps scale your infrastructure without users even noticing

Step-by-Step: Setting Up an Application Load Balancer (ALB)
Step 1: Launch Your EC2 Instances:
Start by launching at least two EC2 instances (in different Availability Zones if possible). These will serve your application and install Apache or NGINX, app on each. If you don't know how to create instance check out my previous post on creation of instances and installation of webserver such as apache or nginx as i will skipping a lot of steps

Step 2: Create a Target Group

  • Go to EC2 > Target Groups.
  • Click Create target group, choose “Instances” as the target type.

leave the VPC as default or if you have specific configuration
Set the protocol and port (e.g., HTTP, port 80).


then click on next
Register your EC2 instances to the target group.


then click on create target group

Step 3: Create the Load Balancer
Go to EC2 > Load Balancers, then click Create Load Balancer.

Choose Application Load Balancer.


leave the VPC as default and select the the availability zone based on the instance you created

Set the name, select internet-facing or internal, and assign at least two Availability Zones for high availability.

from the above picture click on default action and select the previous target group we created then click on add listener tag, then leave the remaining checks as is, then click on create load balancer.

Step 4: Test Your Setup

  • Grab the DNS name of your ALB from the console.
  • Paste it in your browser — you should see one of your app instances respond.
  • Refresh a few times to see how it balances across servers.

Top comments (0)