09 Loadbalancers - gannurohith/devops-interview-wiki GitHub Wiki

๐Ÿ“ 10 - Load Balancers (Basic to Intermediate Q&A)

  1. What is a Load Balancer in AWS? A Load Balancer automatically distributes incoming application traffic across multiple targets like EC2 instances.

  2. 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)
  3. When should you use an Application Load Balancer? For HTTP/HTTPS traffic with advanced routing (path, host-based) and WebSocket support.

  4. When is a Network Load Balancer appropriate? For TCP/UDP traffic requiring ultra-low latency and static IP support.

  5. What is a Target Group? A logical grouping of instances or IPs used by ALB/NLB to route traffic.

  6. How do health checks work in load balancers? They monitor the health of registered targets and route traffic only to healthy ones.

  7. What protocols does ALB support? HTTP, HTTPS, and WebSocket (ws/wss).

  8. What protocols does NLB support? TCP, TLS, UDP.

  9. Can one Load Balancer route traffic to multiple target groups? Yes, based on rules and listener conditions (for ALB).

  10. What is a listener in ELB? A process that checks for connection requests using a configured protocol and port.

  11. How do you perform SSL termination at the load balancer? Configure an HTTPS listener with an SSL certificate on ALB/NLB.

  12. What is host-based routing in ALB? Route traffic to target groups based on the hostname in the request.

  13. What is path-based routing in ALB? Routes traffic based on the URL path (e.g., /api/* โ†’ backend1).

  14. Can Load Balancers span multiple AZs? Yes, they are designed to be highly available across AZs.

  15. How do you protect your Load Balancer from DDoS attacks? Use AWS Shield (standard is included), WAF for ALB, and security groups.

  16. What are sticky sessions? A feature (session affinity) to bind a user's session to a specific target.

  17. Which Load Balancers support sticky sessions? ALB (via cookies) and Classic Load Balancer (via duration).

  18. What is cross-zone load balancing? Distributes traffic evenly across all targets in all enabled AZs.

  19. Can ALB redirect HTTP to HTTPS? Yes, via listener rules with redirect actions.

  20. What is the idle timeout for Load Balancers? ALB default is 60 seconds, configurable.

  21. Can NLB assign static IPs? Yes, supports static IPs and Elastic IP addresses.

  22. Whatโ€™s the difference between ALB and NLB?

  • ALB: Layer 7, advanced routing
  • NLB: Layer 4, high performance, static IP
  1. How do you monitor Load Balancer metrics? Use CloudWatch metrics like RequestCount, TargetResponseTime, HTTPCode_ELB_5XX, etc.

  2. What causes a 5XX error in ALB? Internal error in the ALB or unresponsive/incompatible target.

  3. How do you register and deregister targets? Use the AWS Console, CLI (register-targets, deregister-targets) or Auto Scaling groups.

  4. Can Load Balancers serve static content? Not directly โ€“ serve via S3/CloudFront; ALB routes dynamic requests.

  5. What are listener rules in ALB? Evaluate conditions (host/path) and forward traffic to appropriate target groups.

  6. What happens if all targets in a group are unhealthy? The Load Balancer returns 503 Service Unavailable.

  7. How do you debug target health issues?

  • Check health check configuration
  • Review logs and metrics
  • Test manually using curl or telnet
  1. Can a Load Balancer route traffic to Lambda functions? Yes, ALB supports Lambda as a target.

10. Load Balancers โ€“ ALB, NLB, CLB (Q&A)

  1. 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).

  2. 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.

  3. 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.

  4. Can an ALB route traffic based on path or hostname? Answer: Yes. ALB supports advanced content-based routing using path and host-based rules.

  5. 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.

  6. 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.

  7. How does health check differ between ALB and NLB? Answer: ALB uses HTTP/HTTPS health checks; NLB uses TCP or custom health checks.

  8. 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.

  9. How can you redirect HTTP to HTTPS in ALB? Answer: Add a listener rule on HTTP port to return a redirect (302) to HTTPS.

  10. 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.

  11. Can an ALB support WebSocket or gRPC traffic? Answer: Yes. ALB supports WebSocket and gRPC (HTTP/2) for real-time and streaming protocols.

  12. 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.

  13. How do you secure access to your ALB endpoints? Answer: Use HTTPS listeners with ACM TLS certs, restrict access using security groups and WAF.

  14. 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.

  15. 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.

  16. 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).

  17. How can you integrate ALB with Auto Scaling? Answer: Attach the target group to the Auto Scaling group so new instances register automatically.

  18. How to troubleshoot high latency in ELB? Answer: Analyze CloudWatch metrics (TargetResponseTime, HealthyHostCount), check app/server logs, and confirm health check paths.

  19. What is deregistration delay in ALB? Answer: Time period before stopping traffic to a target during scale-in or manual removal (default: 300s).

  20. How does NLB handle sudden traffic spikes? Answer: NLB scales automatically and is optimized for spike traffic with low latency.

  21. When should you choose CLB? Answer: Only for legacy workloads or apps that do not require advanced routing or modern protocols.

  22. Can you use Lambda with ALB? Answer: Yes. ALB supports invoking Lambda functions as targets in target groups.

  23. How do you protect your ALB from DDoS attacks? Answer: Use AWS Shield Standard (default), Shield Advanced (paid), WAF rules, and rate-based protection.

  24. What is Gateway Load Balancer (GLB)? Answer: Specialized LB for deploying and scaling third-party virtual appliances like firewalls.

  25. How do you monitor ELB performance? Answer: Use CloudWatch metrics (RequestCount, TargetResponseTime, HTTPCode_ELB_5XX, etc.), enable access logs, and X-Ray tracing.