load-balancing-patterns

Configure L4 and L7 load balancers with health checks, session persistence, and multi-region failover.

1|Updated Feb 24, 2026
One-click install
npx skills add https://github.com/masermediagroup-stack/maser-media --skill load-balancing-patterns-masermediagroup-stack
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: load-balancing-patterns
Source: https://github.com/masermediagroup-stack/maser-media/tree/main/.cursor/skills/community/ai-design-components/skills/load-balancing-patterns
Command: npx skills add https://github.com/masermediagroup-stack/maser-media --skill load-balancing-patterns-masermediagroup-stack

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Choosing and configuring the right load balancing solution is complex: teams must decide between L4 and L7, cloud-managed versus self-managed options, health check strategies, and session persistence models, often producing misconfigured infrastructure that causes downtime or uneven traffic distribution. ## Core Features & Use Cases - Load Balancer Selection: Decision frameworks for L4 vs L7, cloud-managed (AWS ALB/NLB, GCP, Azure) versus self-managed (NGINX, HAProxy, Envoy, Traefik), and Kubernetes ingress controllers. - Production Configurations: Ready-to-adapt examples for NGINX, HAProxy, Envoy, Traefik, Kubernetes Ingress, Gateway API, and Terraform for AWS, GCP, and Azure. - Health Checks & Sessions: Liveness/readiness endpoint design, hysteresis to prevent flapping, sticky sessions, Redis-backed shared session stores, and JWT-based stateless authentication. - Use Case: You are deploying a web application to Kubernetes across two regions. Use this Skill to select an ingress controller, configure path-based routing with TLS, define readiness probes, and set up Route 53 failover between regions. ## Quick Start Use the load-balancing-patterns skill to design a load balancing setup for my application, including the balancer configuration, health checks, and session strategy.

Frequently Asked Questions about load-balancing-patterns

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I choose between Layer 4 and Layer 7 load balancing?▼

Choose L4 for non-HTTP protocols, ultra-low latency, and high throughput such as databases or gaming servers. Choose L7 for HTTP/HTTPS applications needing content-based routing by URL, headers, or cookies, plus SSL termination and WAF integration.

NGINX vs HAProxy vs Envoy: which load balancer should I use?▼

NGINX suits general-purpose web stacks, HAProxy delivers maximum throughput with the lowest resource usage and works well for database load balancing, and Envoy fits microservices and service mesh setups needing dynamic xDS configuration. Traefik is best for Docker and Kubernetes with automatic service discovery.

How do I configure health checks for a load balancer?▼

Use a shallow liveness endpoint like /health/live for process checks and a deep readiness endpoint like /health/ready that validates database and cache connectivity. Apply hysteresis, such as 3 failures to mark down and 2 successes to mark up, to prevent flapping.

Does AWS ALB support sticky sessions?▼

Yes, AWS ALB supports cookie-based stickiness configured on the target group with a cookie duration. However, shared session stores like Redis or client-side JWT tokens are recommended instead, since sticky sessions cause uneven load distribution and session loss on server failure.

How do I set up multi-region failover with load balancing?▼

Use DNS-based failover such as AWS Route 53 failover routing with health checks on the primary region, automatically shifting traffic to a secondary region. AWS Global Accelerator provides anycast IPs with automatic regional failover for Layer 4 traffic.

Why are my backend servers flapping between healthy and unhealthy?▼

Flapping usually results from health check timeouts that are too short, thresholds that are too low, or network instability. Increase the check interval and timeout, require multiple consecutive failures before marking down, and use deep readiness checks instead of shallow ones.