Elastic Load Balancing (ELB) is a core component of scalable AWS architectures. While many professionals understand the basics, mastering ELB advanced routing, ALB rules, and load balancer stickiness can significantly improve traffic distribution AWS-wide and optimize application performance. This blog explores these concepts in depth and provides practical guidance for both interview preparation and real-world application.

Understanding Elastic Load Balancing

Elastic Load Balancing automatically distributes incoming traffic across multiple targets, such as Amazon EC2 instances, containers, or IP addresses. ELB improves fault tolerance, ensures high availability, and supports scalability by balancing traffic efficiently.

There are three main types of ELB:

  1. Application Load Balancer (ALB) – Operates at Layer 7 (HTTP/HTTPS), supports advanced routing rules, host-based and path-based routing.
  2. Network Load Balancer (NLB) – Operates at Layer 4 (TCP/UDP), handles millions of requests per second with ultra-low latency.
  3. Gateway Load Balancer (GLB) – Simplifies deployment of virtual appliances in a scalable manner.

For advanced routing, ALB is the primary focus because of its rich rule-based traffic management capabilities.

ALB Rules: Advanced Routing Patterns

ALB rules determine how requests are routed to targets. These rules allow flexible and precise traffic distribution.

Core Components of ALB Rules

  • Listener: Monitors incoming traffic on a specific port (HTTP/HTTPS).
  • Rule Conditions: Define routing logic (e.g., host header, path, HTTP methods, query strings, or source IP).
  • Target Groups: Collections of resources (EC2 instances, Lambda functions, IPs) that receive traffic when a rule matches.

Common ALB Routing Strategies

  1. Host-Based Routing
    Routes traffic based on the domain name in the request.
    Example: app1.example.com → Target Group A, app2.example.com → Target Group B
  2. Path-Based Routing
    Routes traffic based on URL paths.
    Example: /api/* → API server, /web/* → Web server
  3. Query Parameter Routing
    Routes traffic based on query strings for specialized scenarios.
  4. HTTP Header and Method Routing
    Allows routing based on request headers or HTTP methods, useful for A/B testing or feature rollout.
  5. Priority Rules
    Rules are evaluated in order of priority. The first match determines the target group. A default rule handles unmatched requests.

Load Balancer Stickiness: Session Persistence

Stickiness ensures a client continues to interact with the same target during a session. This is critical for stateful applications like shopping carts or personalized dashboards.

How Stickiness Works

  • ALB generates a cookie (AWSALB) that tracks client requests.
  • Subsequent requests from the same client are routed to the same target within a defined duration.
  • Stickiness can be enabled or disabled per target group and configured with a session duration.

Use Cases

  • Applications requiring session consistency
  • Avoiding repeated authentication challenges
  • Supporting legacy applications that do not store session state externally

Tip: Overuse of stickiness can create uneven traffic distribution. Combine stickiness with auto-scaling to maintain performance.

Traffic Distribution in AWS

Proper traffic distribution ensures workloads are highly available and resilient.

Weighted Target Groups

  • ALB supports forwarding traffic to multiple target groups with defined weights.
  • Useful for gradual traffic shifts during blue-green deployments or canary releases.

Health Checks

  • ALB constantly monitors the health of targets.
  • Only healthy targets receive traffic, preventing downtime and ensuring ELB optimization.

Cross-Zone Load Balancing

  • Distributes traffic evenly across multiple Availability Zones.
  • Reduces hot spots and improves fault tolerance.

ELB Optimization Tips

  1. Enable Access Logs – Use Amazon S3 to store detailed request logs for debugging and analytics.
  2. TLS Termination – Offload SSL/TLS processing to the ALB to reduce compute overhead on targets.
  3. Connection Draining – Allows existing connections to complete before deregistering a target.
  4. Dynamic Scaling – Combine ELB with Auto Scaling to handle varying workloads efficiently.
  5. Security Groups – Restrict inbound traffic to only necessary ports and sources.

Conclusion

Mastering ELB advanced concepts such as ALB rules, load balancer stickiness, and traffic distribution AWS strategies empowers cloud architects to design highly available, resilient, and optimized applications. By understanding ELB optimization, session persistence, and routing patterns, you can improve performance, ensure smooth user experiences, and handle complex workloads efficiently. These skills are essential for both interviews and real-world cloud architecture.