09 Loadbalancers - gannurohith/devops-interview-wiki GitHub Wiki
๐ 10 - Load Balancers (Basic to Intermediate Q&A)
-
What is a Load Balancer in AWS? A Load Balancer automatically distributes incoming application traffic across multiple targets like EC2 instances.
-
What are the types of Load Balancers in AWS?
- Application Load Balancer (ALB)
- Network Load Balancer (NLB)
- Gateway Load Balancer (GLB)
- Classic Load Balancer (deprecated)
-
When should you use an Application Load Balancer? For HTTP/HTTPS traffic with advanced routing (path, host-based) and WebSocket support.
-
When is a Network Load Balancer appropriate? For TCP/UDP traffic requiring ultra-low latency and static IP support.
-
What is a Target Group? A logical grouping of instances or IPs used by ALB/NLB to route traffic.
-
How do health checks work in load balancers? They monitor the health of registered targets and route traffic only to healthy ones.
-
What protocols does ALB support? HTTP, HTTPS, and WebSocket (ws/wss).
-
What protocols does NLB support? TCP, TLS, UDP.
-
Can one Load Balancer route traffic to multiple target groups? Yes, based on rules and listener conditions (for ALB).
-
What is a listener in ELB? A process that checks for connection requests using a configured protocol and port.
-
How do you perform SSL termination at the load balancer? Configure an HTTPS listener with an SSL certificate on ALB/NLB.
-
What is host-based routing in ALB? Route traffic to target groups based on the hostname in the request.
-
What is path-based routing in ALB? Routes traffic based on the URL path (e.g.,
/api/*
โ backend1). -
Can Load Balancers span multiple AZs? Yes, they are designed to be highly available across AZs.
-
How do you protect your Load Balancer from DDoS attacks? Use AWS Shield (standard is included), WAF for ALB, and security groups.
-
What are sticky sessions? A feature (session affinity) to bind a user's session to a specific target.
-
Which Load Balancers support sticky sessions? ALB (via cookies) and Classic Load Balancer (via duration).
-
What is cross-zone load balancing? Distributes traffic evenly across all targets in all enabled AZs.
-
Can ALB redirect HTTP to HTTPS? Yes, via listener rules with redirect actions.
-
What is the idle timeout for Load Balancers? ALB default is 60 seconds, configurable.
-
Can NLB assign static IPs? Yes, supports static IPs and Elastic IP addresses.
-
Whatโs the difference between ALB and NLB?
- ALB: Layer 7, advanced routing
- NLB: Layer 4, high performance, static IP
-
How do you monitor Load Balancer metrics? Use CloudWatch metrics like
RequestCount
,TargetResponseTime
,HTTPCode_ELB_5XX
, etc. -
What causes a 5XX error in ALB? Internal error in the ALB or unresponsive/incompatible target.
-
How do you register and deregister targets? Use the AWS Console, CLI (
register-targets
,deregister-targets
) or Auto Scaling groups. -
Can Load Balancers serve static content? Not directly โ serve via S3/CloudFront; ALB routes dynamic requests.
-
What are listener rules in ALB? Evaluate conditions (host/path) and forward traffic to appropriate target groups.
-
What happens if all targets in a group are unhealthy? The Load Balancer returns 503 Service Unavailable.
-
How do you debug target health issues?
- Check health check configuration
- Review logs and metrics
- Test manually using curl or telnet
- Can a Load Balancer route traffic to Lambda functions? Yes, ALB supports Lambda as a target.
10. Load Balancers โ ALB, NLB, CLB (Q&A)
-
What are the three types of Elastic Load Balancers in AWS? Answer: Application Load Balancer (ALB), Network Load Balancer (NLB), and Classic Load Balancer (CLB).
-
When should you use ALB over NLB? Answer: ALB for HTTP/HTTPS traffic with Layer 7 routing; NLB for high-performance TCP/UDP traffic at Layer 4.
-
What is the role of target groups in ALB? Answer: Target groups contain registered targets (instances, IPs, or Lambda) and are the routing destination for listeners.
-
Can an ALB route traffic based on path or hostname? Answer: Yes. ALB supports advanced content-based routing using path and host-based rules.
-
What is a listener in context of ELB? Answer: A process that checks for incoming connections using protocol and port rules, forwarding them to target groups.
-
How does NLB handle millions of requests per second? Answer: NLB is designed for ultra-high throughput and low latency using static IPs and optimized Layer 4 routing.
-
How does health check differ between ALB and NLB? Answer: ALB uses HTTP/HTTPS health checks; NLB uses TCP or custom health checks.
-
What is stickiness (session affinity) and how is it used? Answer: Stickiness binds a user session to a specific target. Enabled using cookies in ALB or client IP in NLB.
-
How can you redirect HTTP to HTTPS in ALB? Answer: Add a listener rule on HTTP port to return a redirect (302) to HTTPS.
-
What is cross-zone load balancing? Answer: Distributes traffic evenly across all targets in all AZs. Enabled by default in ALB, optional in NLB/CLB.
-
Can an ALB support WebSocket or gRPC traffic? Answer: Yes. ALB supports WebSocket and gRPC (HTTP/2) for real-time and streaming protocols.
-
What happens if all targets fail the health check? Answer: The load balancer stops routing traffic to unhealthy targets. 5xx errors or timeouts may occur.
-
How do you secure access to your ALB endpoints? Answer: Use HTTPS listeners with ACM TLS certs, restrict access using security groups and WAF.
-
What is the role of SNI in ALB? Answer: Server Name Indication allows ALB to support multiple SSL certificates on the same listener for different domains.
-
How do you log traffic from a Load Balancer? Answer: Enable access logs and store them in an S3 bucket. Logs include request/response details.
-
Whatโs the difference between instance and IP mode in target groups? Answer: Instance mode routes to EC2 instance ID; IP mode routes to any IP (e.g., ECS tasks, on-prem systems).
-
How can you integrate ALB with Auto Scaling? Answer: Attach the target group to the Auto Scaling group so new instances register automatically.
-
How to troubleshoot high latency in ELB? Answer: Analyze CloudWatch metrics (TargetResponseTime, HealthyHostCount), check app/server logs, and confirm health check paths.
-
What is deregistration delay in ALB? Answer: Time period before stopping traffic to a target during scale-in or manual removal (default: 300s).
-
How does NLB handle sudden traffic spikes? Answer: NLB scales automatically and is optimized for spike traffic with low latency.
-
When should you choose CLB? Answer: Only for legacy workloads or apps that do not require advanced routing or modern protocols.
-
Can you use Lambda with ALB? Answer: Yes. ALB supports invoking Lambda functions as targets in target groups.
-
How do you protect your ALB from DDoS attacks? Answer: Use AWS Shield Standard (default), Shield Advanced (paid), WAF rules, and rate-based protection.
-
What is Gateway Load Balancer (GLB)? Answer: Specialized LB for deploying and scaling third-party virtual appliances like firewalls.
-
How do you monitor ELB performance? Answer: Use CloudWatch metrics (RequestCount, TargetResponseTime, HTTPCode_ELB_5XX, etc.), enable access logs, and X-Ray tracing.