When distributing traffic across multiple servers or regions, use this skill to select and configure the appropriate load balancing solution (L4/L7, cloud-managed, self-managed, or Kubernetes ingress) with proper health checks and session management.
npx skills add https://github.com/ancoleman/ai-design-components --skill load-balancing-patterns
Distribute traffic across infrastructure using the appropriate load balancing approach, from simple round-robin to global multi-region failover.
Use load-balancing-patterns when:
Layer 4 (L4) - Transport Layer:
Layer 7 (L7) - Application Layer:
For detailed comparison including performance benchmarks and hybrid approaches, see references/l4-vs-l7-comparison.md.
| Algorithm | Distribution Method | Use Case |
|-----------|-------------------|----------|
| Round Robin | Sequential | Stateless, similar servers |
| Weighted Round Robin | Capacity-based | Different server specs |
| Least Connections | Fewest active connections | Long-lived connections |
| Least Response Time | Fastest server | Performance-sensitive |
| IP Hash | Client IP-based | Session persistence |
| Resource-Based | CPU/memory metrics | Varying workloads |
Shallow (Liveness): Is the process alive?
/health/live or /liveDeep (Readiness): Can the service handle requests?
/health/ready or /readyHealth Check Hysteresis: Different thresholds for marking up vs down to prevent flapping
For complete health check implementation patterns, see references/health-check-strategies.md.
Application Load Balancer (ALB) - Layer 7:
Network Load Balancer (NLB) - Layer 4:
Global Accelerator - Layer 4 Global:
Application LB (L7): Global HTTPS LB, Cloud CDN integration, Cloud Armor (WAF/DDoS)
Network LB (L4): Regional TCP/UDP, pass-through balancing, session affinity
Cloud Load Balancing: Single anycast IP, global distribution, backend buckets
Application Gateway (L7): WAF integration, URL-based routing, SSL termination, autoscaling
Load Balancer (L4): Basic and Standard SKUs, health probes, HA ports
Traffic Manager (Global): DNS-based routing (priority, weighted, performance, geographic)
For complete cloud provider configurations and Terraform examples, see references/cloud-load-balancers.md.
Best for: General-purpose HTTP/HTTPS load balancing, web application stacks
Capabilities:
Basic configuration:
upstream backend {
least_conn;
server backend1.example.com:8080 weight=3;
server backend2.example.com:8080 weight=2;
keepalive 32;
}
server {
listen 80;
location / {
proxy_pass http://backend;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
}
For complete NGINX patterns and advanced configurations, see references/nginx-patterns.md.
Best for: Maximum performance, database load balancing, resource efficiency
Capabilities:
Basic configuration:
frontend http_front
bind *:80
default_backend web_servers
backend web_servers
balance roundrobin
option httpchk GET /health
server web1 192.168.1.101:8080 check
server web2 192.168.1.102:8080 check
For complete HAProxy patterns, see references/haproxy-patterns.md.
Best for: Microservices, Kubernetes, service mesh integration
Capabilities:
For complete Envoy patterns, see references/envoy-patterns.md.
Best for: Docker/Kubernetes environments, dynamic configuration, ease of use
Capabilities:
For complete Traefik patterns, see references/traefik-patterns.md.
| Controller | Best For | Strengths |
|------------|----------|-----------|
| NGINX Ingress (F5) | General purpose | Stability, wide adoption, mature features |
| Traefik | Dynamic environments | Easy configuration, service discovery |
| HAProxy Ingress | High performance | Advanced L7 routing, reliability |
| Envoy (Contour/Gateway) | Service mesh | Rich L7 features, extensibility |
| Kong | API-heavy apps | JWT auth, rate limiting, plugins |
| Cloud Provider | Single-cloud | Native cloud integration |
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: app-ingress
annotations:
nginx.ingress.kubernetes.io/ssl-redirect: "true"
nginx.ingress.kubernetes.io/affinity: "cookie"
spec:
ingressClassName: nginx
tls:
- hosts:
- app.example.com
secretName: app-tls
rules:
- host: app.example.com
http:
paths:
- path: /api
pathType: Prefix
backend:
service:
name: api-service
port:
number: 80
- path: /
pathType: Prefix
backend:
service:
name: web-service
port:
number: 80
For complete Kubernetes ingress examples and Gateway API patterns, see references/kubernetes-ingress.md.
Cookie-Based: Load balancer sets cookie to track server affinity
IP Hash: Hash client IP to select backend server
Drawbacks: Uneven load distribution, session lost on server failure, complicates scaling
Architecture: Stateless application servers + centralized session storage (Redis, Memcached)
Benefits:
JWT (JSON Web Tokens): Server generates signed token, client stores and sends with requests
Benefits:
For complete session management patterns and code examples, see references/session-persistence.md.
Route users to nearest server based on geographic location:
Primary/secondary region configuration:
Combine load balancing with CDN:
For complete global load balancing examples with Terraform, see references/global-load-balancing.md.
Choose L4 when:
Choose L7 when:
Choose Cloud-Managed when:
Choose Self-Managed when:
Complete working examples available in examples/ directory:
Cloud Providers:
examples/aws/alb-terraform.tf - AWS ALB with path-based routingexamples/aws/nlb-terraform.tf - AWS NLB for TCP load balancingSelf-Managed:
examples/nginx/http-load-balancing.conf - NGINX HTTP reverse proxyexamples/haproxy/http-lb.cfg - HAProxy configurationexamples/envoy/basic-lb.yaml - Envoy cluster configurationexamples/traefik/kubernetes-ingress.yaml - Traefik IngressRouteKubernetes:
examples/kubernetes/nginx-ingress.yaml - NGINX Ingress with TLSexamples/kubernetes/traefik-ingress.yaml - Traefik IngressRouteexamples/kubernetes/gateway-api.yaml - Gateway API configurationThroughput: Requests per second, bytes transferred, connection rate
Latency: Request duration (p50, p95, p99), backend response time, SSL handshake time
Errors: HTTP error rates (4xx, 5xx), backend connection failures, health check failures
Resource Utilization: CPU, memory, active connections, connection queue depth
Health: Healthy/unhealthy backend count, health check success rate
Enable access logs for request/response details, client IPs, response times, error tracking
Symptoms: One server receives disproportionate traffic
Causes: Sticky sessions with few clients, IP hash with NAT concentration, long-lived connections
Solutions: Switch to least connections, disable sticky sessions, implement connection draining
Symptoms: Servers rapidly transition between healthy/unhealthy
Causes: Health check timeout too short, threshold too low, network instability
Solutions: Increase interval and timeout, implement hysteresis, use deep health checks
Symptoms: Users logged out when server fails
Causes: Sticky sessions without replication, in-memory sessions
Solutions: Implement shared session store (Redis), use client-side tokens (JWT)
Related Skills:
infrastructure-as-code - Deploy load balancers via Terraform/Pulumikubernetes-operations - Ingress controllers for K8s traffic managementnetwork-architecture - Network design and topology for load balancingdeploying-applications - Blue-green and canary deployments via load balancersobservability - Load balancer metrics, access logs, distributed tracingsecurity-hardening - WAF integration, rate limiting, DDoS protectionservice-mesh - Envoy as both ingress and service mesh proxyimplementing-tls - TLS termination and certificate management| Use Case | Recommended Solution |
|----------|---------------------|
| HTTP web app (AWS) | ALB |
| Non-HTTP protocol (AWS) | NLB |
| Kubernetes HTTP ingress | NGINX Ingress or Traefik |
| Maximum performance | HAProxy |
| Service mesh | Envoy |
| Docker Swarm | Traefik |
| Multi-cloud portable | NGINX or HAProxy |
| Global distribution | CloudFlare, AWS Global Accelerator |
| Traffic Pattern | Algorithm |
|-----------------|-----------|
| Stateless, similar servers | Round Robin |
| Stateless, different capacity | Weighted Round Robin |
| Long-lived connections | Least Connections |
| Performance-sensitive | Least Response Time |
| Session persistence needed | IP Hash or Cookie |
| Varying server load | Resource-Based |
| Service Type | Check Type | Interval | Timeout |
|--------------|------------|----------|---------|
| Web app | HTTP /health | 10s | 3s |
| API | HTTP /health/ready | 10s | 5s |
| Database | TCP connect | 5s | 2s |
| Critical service | HTTP deep check | 5s | 3s |
| Background worker | HTTP /live | 30s | 5s |
Load balancing is essential for distributing traffic, ensuring high availability, and enabling horizontal scaling. Choose L4 for raw performance and non-HTTP protocols, L7 for intelligent content-based routing. Prefer cloud-managed load balancers for simplicity and auto-scaling, self-managed for multi-cloud portability and advanced features. Implement proper health checks with hysteresis, avoid sticky sessions when possible, and monitor key metrics continuously.
For deployment patterns, see examples in examples/aws/, examples/nginx/, examples/kubernetes/, and other provider directories.
Assess Kubernetes workloads and cluster configuration for AKS Automatic compatibility. Identifies incompatibilities, generates fixes, and guides migration from AKS Standard to AKS Automatic. WHEN: migrate to AKS Automatic, check AKS Automatic readiness, validate manifests for Automatic, assess cluster for Automatic compatibility, fix deployment for Automatic compatibility, identify AKS Automatic migration blockers, is my cluster ready for AKS Automatic.
Discovers available Azure OpenAI model capacity across regions and projects. Analyzes quota limits, compares availability, and recommends optimal deployment locations based on capacity requirements. USE FOR: find capacity, check quota, where can I deploy, capacity discovery, best region for capacity, multi-project capacity search, quota analysis, model availability, region comparison, check TPM availability. DO NOT USE FOR: actual deployment (hand off to preset or customize after discovery), quota increase requests (direct user to Azure Portal), listing existing deployments.
Interactive guided deployment flow for Azure OpenAI models with full customization control. Step-by-step selection of model version, SKU (GlobalStandard/Standard/ProvisionedManaged), capacity, RAI policy (content filter), and advanced options (dynamic quota, priority processing, spillover). USE FOR: custom deployment, customize model deployment, choose version, select SKU, set capacity, configure content filter, RAI policy, deployment options, detailed deployment, advanced deployment, PTU deployment, provisioned throughput. DO NOT USE FOR: quick deployment to optimal region (use preset).
Unified Azure OpenAI model deployment skill with intelligent intent-based routing. Handles quick preset deployments, fully customized deployments (version/SKU/capacity/RAI policy), and capacity discovery across regions and projects. USE FOR: deploy model, deploy gpt, create deployment, model deployment, deploy openai model, set up model, provision model, find capacity, check model availability, where can I deploy, best region for model, capacity analysis. DO NOT USE FOR: listing existing deployments (use foundry_models_deployments_list MCP tool), deleting deployments, agent creation (use agent/create), project creation (use project/create).
Intelligently deploys Azure OpenAI models to optimal regions by analyzing capacity across all available regions. Automatically checks current region first and shows alternatives if needed. USE FOR: quick deployment, optimal region, best region, automatic region selection, fast setup, multi-region capacity check, high availability deployment, deploy to best location. DO NOT USE FOR: custom SKU selection (use customize), specific version selection (use customize), custom capacity configuration (use customize), PTU deployments (use customize).
This skill should be used when working with LaminDB, an open-source data framework for biology that makes data queryable, traceable, reproducible, and FAIR. Use when managing biological datasets (scRNA-seq, spatial, flow cytometry, etc.), tracking computational workflows, curating and validating data with biological ontologies, building data lakehouses, or ensuring data lineage and reproducibility in biological research. Covers data management, annotation, ontologies (genes, cell types, diseases, tissues), schema validation, integrations with workflow managers (Nextflow, Snakemake) and MLOps platforms (W&B, MLflow), and deployment strategies.
Latch platform for bioinformatics workflows. Build pipelines with Latch SDK, @workflow/@task decorators, deploy serverless workflows, LatchFile/LatchDir, Nextflow/Snakemake integration.
Run Python code in the cloud with serverless containers, GPUs, and autoscaling. Use when deploying ML models, running batch processing jobs, scheduling compute-intensive tasks, or serving APIs that require GPU acceleration or dynamic scaling.
Take ancoleman/load-balancing-patterns from the repository into ~/.claude/skills for personal
use, or into .claude/skills inside a project.
The agent identifies a skill by the name field in its header. Two skills with the
same name cannot sit side by side — one of them will be ignored.