load balancer configurations with aws EKS

load balancer using the following three types
aws ALB(L7) configuration aws ALB(L7) + Nginx Ingress(L7) configuration aws NLB(L4) + Nginx Ingress(L7) configuration
Understanding AWS Load Balancing Configurations: A Deep Dive
In today's cloud-native world, effectively managing traffic distribution across your applications is crucial for maintaining high availability and scalability. Let's explore three popular load balancing configurations in AWS and understand their use cases, benefits, and implementation details.
1. AWS Application Load Balancer (ALB) Configuration
The Application Load Balancer operates at Layer 7 (application layer) of the OSI model, making it ideal for HTTP/HTTPS traffic routing.
Key Features
- Content-based routing using path patterns and host-based rules
- Support for WebSocket and HTTP/2 protocols
- Native integration with AWS services
- Built-in SSL/TLS termination
Implementation Steps
- Create an ALB
aws elbv2 create-load-balancer \
--name my-application-lb \
--subnets subnet-12345678 subnet-87654321 \
--security-groups sg-12345678
- Configure Target Groups
aws elbv2 create-target-group \
--name my-targets \
--protocol HTTP \
--port 80 \
--vpc-id vpc-0123456789 \
--target-type instance
- Create Listener Rules
aws elbv2 create-listener \
--load-balancer-arn arn:aws:elasticloadbalancing:region:account-id:loadbalancer/app/my-load-balancer/50dc6c495c0c9188 \
--protocol HTTP \
--port 80
Use Cases
- Web applications requiring path-based routing
- Microservices architectures
- Applications needing advanced request routing capabilities
2. AWS ALB + Nginx Ingress Controller Configuration
This setup combines AWS ALB with Kubernetes Nginx Ingress Controller, providing additional Layer 7 capabilities and fine-grained control.
Architecture Overview
Internet → ALB → Nginx Ingress Controller → Kubernetes Services → Pods
Implementation Steps
- Install Nginx Ingress Controller
helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx
helm repo update
helm install nginx-ingress ingress-nginx/ingress-nginx
- Configure ALB Annotations
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: my-ingress
annotations:
kubernetes.io/ingress.class: alb
alb.ingress.kubernetes.io/scheme: internet-facing
spec:
rules:
- host: example.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: nginx-ingress-controller
port:
number: 80
Benefits
- Advanced traffic management capabilities
- Better control over HTTP routing
- Support for custom headers and SSL configurations
- Rate limiting and access control
3. AWS Network Load Balancer (NLB) + Nginx Ingress Controller Configuration
This configuration leverages NLB's Layer 4 capabilities with Nginx's Layer 7 features, offering high performance and advanced routing.
Architecture Overview
Internet → NLB → Nginx Ingress Controller → Kubernetes Services → Pods
Implementation Steps
- Create NLB
aws elbv2 create-load-balancer \
--name my-network-lb \
--type network \
--subnets subnet-12345678
- Configure Nginx Ingress Controller with NLB
controller:
service:
type: LoadBalancer
annotations:
service.beta.kubernetes.io/aws-load-balancer-type: nlb
- Deploy Ingress Resources
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: my-ingress
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /
spec:
rules:
- host: example.com
http:
paths:
- path: /app
pathType: Prefix
backend:
service:
name: my-service
port:
number: 80
Benefits
- Lower latency due to Layer 4 processing
- Preserved client IP addresses
- Support for non-HTTP/HTTPS protocols
- Static IP addresses for load balancer endpoints
Comparison of Configurations
Performance
- ALB: Good for HTTP/HTTPS traffic, moderate latency
- ALB + Nginx: Better control but slightly higher latency
- NLB + Nginx: Lowest latency, best for high-performance requirements
Cost Considerations
- ALB: Higher cost per hour, but includes advanced features
- ALB + Nginx: Additional compute costs for Nginx
- NLB + Nginx: Lower NLB costs, but requires Nginx resources
Management Complexity
- ALB: Easiest to manage, native AWS integration
- ALB + Nginx: Moderate complexity, requires Kubernetes knowledge
- NLB + Nginx: Most complex, requires networking expertise
Best Practices
-
Monitoring and Logging
- Enable access logs for troubleshooting
- Set up CloudWatch metrics
- Configure health checks appropriately
-
Security
- Implement SSL/TLS termination
- Configure security groups properly
- Use AWS WAF for additional protection
-
High Availability
- Deploy across multiple availability zones
- Implement proper health checks
- Use auto-scaling groups for backend instances
Conclusion
Each configuration has its unique advantages:
- Use ALB alone for simple HTTP/HTTPS applications
- Choose ALB + Nginx when you need advanced Layer 7 features in Kubernetes
- Opt for NLB + Nginx for high-performance requirements or when you need static IPs
Consider your specific requirements around performance, cost, and management complexity when choosing between these configurations. Remember to properly monitor and secure your chosen setup for optimal operation.

About the author
Anvesh Reddy · Cloud & DevOps Consultant
Welcome to my blog! I'm Anvesh Reddy, a Cloud & DevOps Consultant passionate about sharing knowledge on cloud technologies, automation, and best practices.
View all posts by this author