AWS Elastic Load Balancing:
- has the task of distributing traffic throughout the cluster of servers to ensure higher responsiveness and availability of applications, websites, or databases
- automatically distributes the incoming traffic across multiple targets, such as:
- EC2 instances
- containers
- IP addresses
- monitors the health of its registered targets, and routes traffic only to the healthy targets
- targets can be added and removed from load balancer as the needs change, without disrupting the overall flow of requests to the application
- scales your load balancer as your incoming traffic changes over time
- supports the following load balancers:
- Application Load Balancers
- Network Load Balancers
- Gateway Load Balancers
- Classic Load Balancers
Load balancer:
- serves as the single point of contact for clients
- distributes incoming application traffic across multiple targets which increases the availability of your application
- has one or more listeners added to it
Listener:
- checks for connection requests from clients, using the protocol and port that you configure
- has rules defined for it
- a default rule must be defined for each listener, additional rules can be defined optionally
- Rules determine how the load balancer routes requests to its registered targets
- Each rule consists of:
- priority
- one or more actions
- one or more conditions; when conditions for a rule are met, then its actions are performed
- specified target groups
- When load balancer receives a request, it evaluates the listener rules in priority order to determine which rule to apply, and then selects a target from the target group for the rule action.
Target groups:
- Each target group routes requests to one or more registered targets, such as EC2 instances, using the protocol and port number that you specify.
- target can be registered with multiple target groups
- Routing is performed independently for each target group, even when a target is registered with multiple target groups
- health checks are configured per target group
- used to monitor the health of the registered targets
- they are performed on all targets registered to a target group
- they can be configured so that the load balancer can send requests only to the healthy targets
- routing algorithm is configured at the target group level
- default: round robin
- least outstanding requests routing algorithm can alternatively be specified
Why are load balancers a feature of EC2 and not of VPC?
It’s a classic "architectural vs. logical" debate. On the surface, it feels like Load Balancers (LBs) should belong to the VPC because they live inside our network and route traffic within it. However, AWS categorizes Elastic Load Balancing (ELB) under EC2 for a few fundamental reasons.
Here is the breakdown of why they are cousins to the instance, rather than a setting of the network.
1. Compute vs. Connectivity
The VPC is the plumbing of our infrastructure. It defines the IP ranges, subnets, and routing tables—essentially the "where" of our resources.
Load balancers, however, are a managed compute service. Even though we don’t manage the underlying servers, an ELB is actually a fleet of managed EC2 instances running behind the scenes. They perform active work:
- Health Checks: Constantly pinging targets to see if they are alive.
- TLS Termination: Heavy lifting of decrypting and encrypting traffic.
- Layer 7 Logic: Inspecting HTTP headers and cookies to make routing decisions.
Because this requires active processing power (compute), it aligns more closely with the EC2 family than the static configuration of a VPC.
2. The Relationship with Targets
The primary "job" of a load balancer is to manage Targets. Historically, those targets were almost exclusively EC2 instances.
- Auto Scaling Groups (ASG): ELBs are designed to work hand-in-hand with ASGs. When an ASG spins up a new EC2 instance, it automatically registers it with the Load Balancer.
- Tight Integration: The features of an ELB (like connection draining or sticky sessions) are designed to manage the lifecycle of an application running on a server.
3. Organizational Legacy
When AWS launched, the EC2-Classic platform existed before VPCs were even a thing. In those days, we just spun up instances in a flat, shared network. Load balancers were created to distribute traffic among those instances.
When VPCs were introduced later to provide private, isolated networks, the Load Balancing service stayed under the EC2 umbrella because it was already the "Compute Management" hub.
4. Shared Responsibility
If we look at the AWS Management Console, we'll notice a pattern:
- VPC contains "Networking" components (Gateways, ACLs, Peering).
- EC2 contains "Deployment" components (Instances, AMIs, Key Pairs, and Load Balancers).
AWS treats the Load Balancer as an application delivery component rather than a network boundary component.
Comparison at a Glance
Feature VPC (Networking) ELB (Compute/EC2)
---------- ----------------------- --------------------------
Primary Goal Isolation and Routing Availability and Scalability
Action Passive (Permits/Denies traffic) Active (Inspects and Routes traffic)
Unit of Scale IP addresses/Subnets Request throughput/Connections
Billing Free (mostly) for the setup Hourly rate + Capacity Units (LCU)


No comments:
Post a Comment