Cloud / Amazon Elastic Load Balancing (ELB) Interview questions
Last updated
1. What is Amazon Elastic Load Balancing?
Amazon Elastic Load Balancing (ELB) is a managed AWS service that spreads incoming traffic across multiple targets such as EC2 instances, containers, IP addresses and Lambda functions, in one or more Availability Zones.
It keeps checking the health of every target and sends requests only to the healthy ones. The load balancer itself scales automatically with traffic, so you never size or patch servers for it.
- Removes a single point of failure in front of your application
- Supports TLS termination, so certificates are managed in one place
- Integrates with Auto Scaling, ECS, EKS, Route 53, WAF and CloudWatch
ELB comes in four flavours: Application, Network, Gateway and Classic Load Balancer.
Take quiz
Terminates the instance immediately
Keeps sending traffic so it can recover
Stops sending new requests to it until it passes again
Copies its data to another target
You resize its nodes manually
Capacity is fixed when it is created
It only scales if a CloudFront distribution is attached
It scales its own capacity automatically
2. What are the types of load balancers in ELB?
ELB offers four types. Three are current generation and one is legacy.
| Type | OSI layer | Protocols | Typical use |
| Application (ALB) | 7 | HTTP, HTTPS, gRPC, WebSocket | Web apps, microservices, content-based routing |
| Network (NLB) | 4 | TCP, UDP, TCP_UDP, TLS | Extreme performance, static IPs, non-HTTP traffic |
| Gateway (GWLB) | 3 | IP (GENEVE on UDP 6081) | Firewalls and inspection appliances |
| Classic (CLB) | 4 and 7 | TCP, SSL, HTTP, HTTPS | Legacy workloads only |
For new designs, pick ALB for HTTP traffic, NLB for raw TCP/UDP or static IPs, and GWLB for third-party network appliances.
Take quiz
Application Load Balancer
Network Load Balancer
Classic Load Balancer
Gateway Load Balancer
Classic Load Balancer
Application Load Balancer
Gateway Load Balancer
Network Load Balancer
3. What is an Application Load Balancer?
An Application Load Balancer (ALB) works at layer 7 and routes requests by looking at their content: host name, URL path, headers, query string, HTTP method or source IP.
Beyond routing, it can redirect requests, return fixed responses, authenticate users through Cognito or any OIDC provider, and invoke Lambda functions directly. It understands HTTP/2, gRPC and WebSockets.
- Supports security groups and AWS WAF
- Terminates TLS using ACM certificates, with SNI for multiple domains
- Does not give you static IP addresses
Take quiz
Layer 7 (application)
Layer 4 (transport)
Layer 3 (network)
Layer 2 (data link)
Routing by TCP sequence number
Routing by URL path or host header
Routing by MAC address
Routing by subnet CIDR only
4. What is a Network Load Balancer?
A Network Load Balancer (NLB) operates at layer 4 and forwards TCP, UDP, TCP_UDP and TLS connections. It is built to handle millions of requests per second with very low latency and sudden traffic spikes.
Each enabled Availability Zone gets a fixed IP address, and for internet-facing NLBs you can attach an Elastic IP. By default the original client IP reaches instance targets untouched.
- Ideal for gaming, IoT, streaming, DNS and database proxies
- Can sit in front of an ALB to combine static IPs with layer 7 routing
- Backs AWS PrivateLink endpoint services
Take quiz
Path-based routing
A static IP per Availability Zone
Native AWS WAF attachment
Cookie-based authentication
HTTPS
HTTP
UDP
gRPC
5. What is a Gateway Load Balancer?
A Gateway Load Balancer (GWLB) lets you deploy, scale and manage fleets of virtual network appliances such as firewalls, intrusion detection systems and deep packet inspection tools. It acts as a transparent network gateway and a load balancer in one.
Traffic reaches it through a Gateway Load Balancer endpoint that you place in route tables. The GWLB wraps each packet in GENEVE (UDP port 6081) and sends it to an appliance, then forwards the inspected packet on to its destination.
Flows are hashed so both directions of a connection land on the same appliance, which stateful inspection needs.
Take quiz
TCP 443
UDP 4789
UDP 6081
TCP 8080
By pointing a CNAME to the appliance
By attaching an Elastic IP to the GWLB
By configuring a listener rule with a path pattern
Through a GWLB endpoint referenced in route tables
6. What is a Classic Load Balancer?
The Classic Load Balancer (CLB) is the original ELB, now considered legacy. It balances at layer 4 (TCP, SSL) and at a basic layer 7 (HTTP, HTTPS) and registers EC2 instances directly rather than through target groups.
It lacks modern features: no path or host routing, no SNI so one certificate per listener, no Lambda or IP targets, and no WebSocket support on HTTP listeners. EC2-Classic, where CLB first lived, was retired in August 2022.
AWS recommends migrating to ALB or NLB, and the console offers a migration wizard to do it.
Take quiz
It supports Lambda targets
It uses target groups
It supports SNI with multiple certificates
It cannot route by URL path
Migrate to an ALB or NLB
Keep it, it is the preferred type
Replace it with Route 53 only
Move to Gateway Load Balancer
7. What is a target group in ELB?
A target group is a logical set of targets that receives traffic from a load balancer listener. Listener rules point at target groups, not at individual servers.
Each target group has its own protocol and port, health check settings, routing algorithm and attributes like stickiness and deregistration delay. One target can belong to several target groups, which is how a single instance serves multiple ports or apps.
The target type is chosen at creation and cannot change: instance, ip, lambda or alb.
Take quiz
On the target group
On the listener only
In the VPC route table
In the Auto Scaling launch template
instance
S3 bucket
ip
lambda
8. What is a listener in ELB?
A listener is the process that checks for incoming connection requests on a specific protocol and port, such as HTTPS on 443.
On an ALB each listener has a default action plus optional rules that decide where a request goes. On an NLB the listener forwards to a target group, and TLS listeners also hold a certificate. A load balancer can have several listeners, for example 80 for redirects and 443 for the app.
- ALB listener protocols: HTTP, HTTPS
- NLB listener protocols: TCP, UDP, TCP_UDP, TLS
- GWLB uses a single listener that accepts all IP packets
Take quiz
The AMI used by targets
The protocol and port it accepts connections on
The subnet of the targets
The health check path
HTTP
HTTPS
TLS
gRPC
9. What are listener rules in ALB?
A listener rule tells an ALB what to do with a request. Each rule has a priority, one or more conditions and one or more actions. Rules are checked from the lowest priority number upward, and the default rule runs last.
- Conditions: host-header, path-pattern, http-header, http-request-method, query-string, source-ip
- Actions: forward, redirect, fixed-response, authenticate-cognito, authenticate-oidc
aws elbv2 create-rule --listener-arn $LISTENER --priority 10 \ --conditions Field=path-pattern,Values='/api/*' \ --actions Type=forward,TargetGroupArn=$API_TG
Each rule can hold up to five condition values per condition type and a rule can combine several condition types, for example a host header and a path. All conditions in one rule must match (AND), while multiple values inside a single condition are matched with OR.
Take quiz
Priority 20
The default rule
Priority 10
They run in parallel
forward
fixed-response
authenticate-cognito
redirect
10. What is the difference between internet-facing and internal load balancers?
The difference is the scheme. An internet-facing load balancer has public IP addresses, sits in public subnets that route to an internet gateway, and its DNS name resolves to public IPs. It accepts traffic from anywhere that the security groups allow.
An internal load balancer has only private IPs and its DNS name resolves to private addresses, so it is reachable only from inside the VPC, peered VPCs, VPN or Direct Connect.
A common three-tier layout uses an internet-facing ALB for the web tier and an internal ALB between the web and application tiers. Routing and health checks work the same in both.
Take quiz
Public IP addresses
An S3 endpoint
A CloudFront edge
Private IP addresses
Public subnets with a route to an internet gateway
Private subnets with no routes
Only in a peered VPC
Inside the target instances
11. What are health checks in ELB?
A health check is a periodic request the load balancer sends to each target. Targets that keep failing are marked unhealthy and receive no new traffic until they pass again.
These are the ALB defaults you can tune per target group:
| Setting | Default | Meaning |
| Interval | 30 s | Time between checks |
| Timeout | 5 s | Wait before a check counts as failed |
| Healthy threshold | 5 | Consecutive passes to become healthy |
| Unhealthy threshold | 2 | Consecutive failures to become unhealthy |
| Success codes | 200 | HTTP codes treated as healthy |
Point the check at a lightweight path like /health that also confirms the app's critical dependencies are reachable.
Take quiz
200
204
301
Any 2xx or 3xx
1
5
2
10
12. What is cross-zone load balancing?
With cross-zone load balancing, each load balancer node distributes its traffic across all registered targets in every enabled Availability Zone, not just its own. Without it, each node only uses targets in its own zone.
Take two targets in AZ-A and eight in AZ-B. DNS splits traffic 50/50 between the two zone nodes. With cross-zone off, each AZ-A target gets 25% and each AZ-B target about 6%. With it on, every target gets 10%.
| Load balancer | Default |
| ALB | Always on (can be turned off per target group) |
| NLB / GWLB | Off (extra inter-AZ data charges when on) |
| CLB | On in the console, off via API or CLI |
Take quiz
10% of traffic
25% of traffic
50% of traffic
5% of traffic
Enabled and cannot change
Enabled only for TLS
Disabled
Enabled for UDP only
13. What is connection draining (deregistration delay) in ELB?
When a target is deregistered or marked unhealthy it enters the draining state. The load balancer stops sending it new requests but lets in-flight requests finish. This window is the deregistration delay.
The default is 300 seconds, configurable from 0 to 3600. If requests take a second or two, lower it to 30 or so so deployments and scale-in finish faster. For long uploads or WebSockets, keep it higher.
When the delay expires, remaining connections are closed. On an NLB you can also choose whether to terminate connections on deregistration.
Take quiz
30 seconds
60 seconds
300 seconds
900 seconds
They are queued on that target
They are sent at half rate
They fail with 503
They are not sent to that target
14. What are sticky sessions in ELB?
Sticky sessions (session affinity) bind a client to one target for a period so repeat requests land on the same server. You enable them in the target group attributes.
- Duration-based: the ALB issues an
AWSALBcookie, valid from 1 second to 7 days - Application-based: the ALB issues
AWSALBAPPand ties it to your own app cookie - NLB: stickiness is based on the client source IP
The downside is uneven load and lost sessions when a target dies or scales in. A better long-term design keeps session state in ElastiCache or DynamoDB so any target can serve any user.
Take quiz
JSESSIONID
AWSELB-SESSION
X-Sticky-Id
AWSALB
Store session state in ElastiCache or DynamoDB
Disable health checks
Use a single large instance
Turn off cross-zone balancing
15. How do you use an ELB with Auto Scaling groups?
You attach a target group to the Auto Scaling group, and the group handles registration for you.
- Create a target group and an ALB listener that forwards to it
- Attach the target group to the Auto Scaling group
- New instances register automatically once launched, and terminating instances deregister (honouring draining)
- Set the group's health check type to ELB so instances failing load balancer checks are replaced
- Add a target tracking policy on
ALBRequestCountPerTarget
Set a health check grace period that covers boot and app start time, or new instances may be killed before they are ready.
Take quiz
ALBRequestCountPerTarget
NetworkPacketsOut
DiskReadOps
StatusCheckFailed
To disable EC2 status checks
So instances failing load balancer checks get replaced
To enable cross-zone balancing
To increase deregistration delay
16. What is path-based routing in ALB?
Path-based routing sends requests to different target groups based on the URL path. You add a listener rule with a path-pattern condition.
| Path pattern | Forwards to |
| /api/* | api-service target group |
| /images/* | static-content target group |
| default | web-app target group |
Patterns support * and ? wildcards and are case-sensitive. This lets one ALB front several microservices under a single domain.
Order matters. Give specific paths such as /api/v2/* a lower priority number than broader ones like /api/*, or the broader rule will capture the request first. Each target group can have its own health check path, so the API and static fleets are checked independently.
Take quiz
host-header
path-pattern
source-ip
http-request-method
Yes, using listener rules
Yes, but only for UDP
No, it works at layer 4
Yes, with sticky sessions
17. What is host-based routing in ALB?
Host-based routing picks a target group from the Host header, using a host-header condition. For instance, api.example.com goes to the API fleet and shop.example.com to the storefront.
Wildcards work, so *.example.com can match every tenant subdomain. You can combine host and path conditions in one rule, and both are matched case-insensitively for host names.
This is the usual way to host many tenants or services behind one ALB and one public IP set. Pair it with an HTTPS listener holding one certificate per domain, or a wildcard certificate, so SNI picks the right certificate before the host rule picks the target group.
Take quiz
Authorization
Content-Type
Host
X-Forwarded-For
example.com/*
host.*.com
/subdomain/*
*.example.com
18. How do you configure HTTPS on an ALB?
Terminate TLS on the ALB by adding an HTTPS listener with a certificate.
- Request or import a certificate in AWS Certificate Manager
- Create an HTTPS listener on port 443
- Attach the certificate and choose a TLS security policy
- Forward to a target group
- Allow inbound 443 in the ALB security group
Targets can stay on HTTP (SSL offload) or you can use an HTTPS target group to re-encrypt traffic to the backend when compliance requires encryption in transit end to end.
Take quiz
At the client browser only
At Route 53
At the EC2 instance always
At the ALB
AWS Certificate Manager
AWS KMS
AWS Secrets Manager
AWS Config
19. What is the X-Forwarded-For header?
Because the ALB terminates the client connection, your targets see the load balancer's IP, not the user's. The ALB adds X-Forwarded-For containing the client IP so the app can log or act on it.
It also sets X-Forwarded-Proto (http or https) and X-Forwarded-Port. If the request already had an X-Forwarded-For value, the ALB appends the new IP, giving a comma-separated list where the left-most entry is the original client.
Never trust it blindly for security decisions, since clients can send a forged value. An NLB does not use this header; it preserves the source IP instead.
Take quiz
They would otherwise only see the ALB's IP
To authenticate the user
To enable HTTP/2
To compress responses
X-Forwarded-Host-Type
X-Forwarded-Proto
X-Amz-Scheme
X-Real-Port
20. What types of targets can you register with ELB?
The target type depends on the load balancer.
| Target type | ALB | NLB | GWLB |
| instance | Yes | Yes | Yes |
| ip | Yes | Yes | Yes |
| lambda | Yes | No | No |
| alb | No | Yes | No |
ip targets can be private addresses in the VPC, a peered VPC, or on-premises servers reached over VPN or Direct Connect. The alb type lets an NLB forward to an ALB, giving you static IPs in front of layer 7 routing.
Choose ip when targets are containers with their own ENI, when you need several ports on one host, or when the backend lives outside the VPC. Choose instance for classic EC2 fleets managed by Auto Scaling, where registration is automatic.
Take quiz
Network Load Balancer
Application Load Balancer
Gateway Load Balancer
Classic Load Balancer
Gateway Load Balancer
Another ALB directly
Network Load Balancer
Classic Load Balancer
21. How is ELB priced?
ELB pricing has two parts: an hourly charge for each running load balancer, and a usage charge measured in capacity units: LCU for ALB, NLCU for NLB and GLCU for GWLB.
An LCU counts the highest of four dimensions in each hour, and you pay only for that one:
- New connections: 25 per second
- Active connections: 3,000 per minute
- Processed bytes: 1 GB per hour for EC2 targets
- Rule evaluations: 1,000 per second
Public IPv4 addresses used by the load balancer are billed per hour as well, and standard data transfer charges still apply.
Take quiz
By the sum of all four dimensions
By the lowest dimension
By the dimension with the highest consumption
By the number of listeners
Number of target groups
CPU usage of targets
Number of AZs
Rule evaluations
22. How do you secure traffic between an ALB and EC2 targets?
Chain security groups so the targets only accept traffic that came through the load balancer.
- ALB security group: allow inbound 80/443 from the internet (or a restricted CIDR)
- Target security group: allow the app port only from the ALB security group ID, not from 0.0.0.0/0
- Put targets in private subnets with no public IPs
- Use an HTTPS target group if traffic must stay encrypted inside the VPC
- Attach AWS WAF to the ALB for application-layer filtering
Remember the health check port too, otherwise targets turn unhealthy even though the app is fine.
Take quiz
0.0.0.0/0
The VPC route table
The target's own public IP
The ALB's security group ID
Private subnets
Public subnets with Elastic IPs
Outside the VPC
In the same subnet as the NAT gateway only
23. How do you redirect HTTP to HTTPS on an ALB?
Keep an HTTP listener on port 80 whose default action is a redirect to HTTPS on 443. No target group is needed on that listener.
{ "Type": "redirect", "RedirectConfig": { "Protocol": "HTTPS", "Port": "443", "Host": "#{host}", "Path": "/#{path}", "Query": "#{query}", "StatusCode": "HTTP_301" } }
Use HTTP_301 for a permanent redirect. Use HTTP_302 while testing, since browsers cache 301 responses aggressively.
The security group on the ALB must allow port 80 as well as 443, otherwise browsers never reach the redirect. Also confirm the HTTPS listener exists and has a valid certificate before enabling the redirect, or users get a connection error instead of the site.
Take quiz
HTTP_301
HTTP_200
HTTP_302
HTTP_404
The HTTPS listener on port 443
The HTTP listener on port 80
The target group
The Auto Scaling group
24. How do you monitor an ELB with CloudWatch?
ELB publishes metrics to CloudWatch every minute under AWS/ApplicationELB (ALB) or AWS/NetworkELB (NLB). The ones worth alarming on:
| Metric | What it tells you |
| RequestCount | Traffic volume |
| TargetResponseTime | Backend latency |
| HTTPCode_ELB_5XX_Count | Errors generated by the ALB itself |
| HTTPCode_Target_5XX_Count | Errors returned by your app |
| UnHealthyHostCount | Targets failing health checks |
| ActiveConnectionCount | Concurrent client connections |
Pair metrics with access logs when you need per-request detail.
A useful starter alarm set is: UnHealthyHostCount above 0 for five minutes, HTTPCode_ELB_5XX_Count above a small threshold, and TargetResponseTime p95 above your latency budget. Use the load balancer and target group dimensions together to see per-service behaviour, and add the RejectedConnectionCount metric to spot connection limits being hit.
Take quiz
HTTPCode_Target_5XX_Count
HTTPCode_ELB_5XX_Count
RequestCount
TargetResponseTime
AWS/ApplicationELB
AWS/EC2
AWS/NetworkELB
AWS/ELBv3
25. How do you map a custom domain to an ELB?
Every load balancer gets an AWS DNS name like my-alb-123456.us-east-1.elb.amazonaws.com. It resolves to the IPs of the load balancer nodes, and those IPs can change as it scales, so never hardcode them.
Create a Route 53 alias record (A and AAAA) pointing your domain at the load balancer. Alias records work at the zone apex such as example.com, where a CNAME is not allowed, and queries to alias records for AWS resources are free.
With another DNS provider you can use a CNAME for subdomains like www.
Take quiz
CNAME
MX
Route 53 alias record
TXT
They are always private
They are the same as your instances
They expire after 24 hours
They can change as the load balancer scales
26. What is the difference between ALB and NLB?
An ALB is a layer 7 balancer that understands HTTP and makes routing choices from request content. An NLB is a layer 4 balancer that forwards connections without looking inside them.
| Feature | ALB | NLB |
| Protocols | HTTP, HTTPS, gRPC, WebSocket | TCP, UDP, TCP_UDP, TLS |
| Routing | Host, path, header, query, method | Port and protocol only |
| Static / Elastic IP | No | Yes, per AZ |
| Client IP to target | Via X-Forwarded-For | Preserved for instance targets |
| AWS WAF | Yes | No |
| Latency | Milliseconds | Ultra-low (microseconds range) |
| Lambda targets | Yes | No |
Choose ALB for web apps and microservices, and NLB for non-HTTP protocols, fixed IPs or extreme throughput.
Cost and operations differ too. Both bill by the hour plus capacity units, but NLB's lower per-connection overhead suits very chatty, long-lived connections, while ALB's rich rules reduce the number of load balancers you need because one ALB can front many services.
Take quiz
NLB
GWLB
None of them
ALB
NLB
ALB
Both equally
Neither
27. When would you choose NLB over ALB?
Pick an NLB when the job is moving connections quickly and predictably rather than understanding requests.
- The protocol is not HTTP: UDP games, MQTT, DNS, SMTP, custom TCP
- Partners need to allowlist fixed IPs
- You face sudden spikes or millions of requests per second
- You are publishing a service via AWS PrivateLink
- Backends need the original client IP, or you want TLS passthrough
If you need both, register an ALB as an NLB target: clients see static IPs and you keep path and host routing behind them.
Stay with an ALB when you want layer 7 features: WAF, Cognito or OIDC login, redirects, header or path routing, or Lambda targets. Those are exactly the things an NLB cannot do, since it never reads the request.
Take quiz
Network Load Balancer
Application Load Balancer
Classic Load Balancer with HTTP listener
Route 53 geolocation only
WAF on the NLB
Static IPs together with layer 7 routing
UDP support on the ALB
Removal of health checks
28. Why does an NLB provide static IP addresses?
An NLB creates one load balancer node per enabled subnet, and each node is backed by a network interface with a fixed IP. For internet-facing NLBs you can assign an Elastic IP to each node, and for internal ones you can pick the private IP from the subnet.
This helps when customers or partners firewall by IP address. An ALB cannot do this because its node IPs change as it scales.
To get static IPs for an ALB, either put an NLB in front with an ALB-type target group, or use AWS Global Accelerator, which gives two static anycast IPs.
Plan the subnets carefully. Every AZ you enable gets its own address, so a design with three AZs gives partners three IPs to allowlist. Adding an AZ later adds a new IP, which partners must be told about before you switch it on.
Take quiz
Each target instance
Each enabled subnet / Availability Zone node
Each listener rule
Each target group
Amazon CloudFront
AWS Direct Connect
AWS Global Accelerator
Amazon Route 53 Resolver
29. How does ALB decide which target gets a request?
The ALB picks a target group first through listener rules, then picks a target inside it using the group's routing algorithm. Three are available:
| Algorithm | How it picks | Best for |
| Round robin (default) | Targets in turn | Similar requests, similar targets |
| Least outstanding requests | Target with the fewest in-flight requests | Varying request durations, mixed capacity |
| Weighted random | Random with automatic anomaly mitigation | Avoiding targets that return errors |
Slow start mode works only with round robin. An NLB, by contrast, uses a flow hash on the connection tuple, so one connection always stays on one target.
Pick least outstanding requests when some requests take seconds and others milliseconds, because round robin can pile slow requests on one target. Pick weighted random when a faulty target returns errors fast, since anomaly mitigation shifts traffic away from it automatically. Round robin stays fine for uniform workloads.
Take quiz
Round robin
Source IP hash
Least outstanding requests
Random with no weights
Least outstanding requests
Weighted random
Flow hash
Round robin
30. What happens when all targets in a target group are unhealthy?
If every target fails health checks in all enabled Availability Zones, the ALB fails open: it sends requests to all targets anyway, ignoring health status.
The reasoning is that a wrong health check (a bad path, a changed port) should not turn a working app into a total outage. Some requests may still succeed, and the app keeps serving.
This is different from a target group with no registered targets, where the ALB returns 503. Treat fail open as a signal to fix your health check or app quickly, since users may see errors.
Before relying on this behaviour, set CloudWatch alarms on UnHealthyHostCount. Fail open protects against a mistaken health check, but if the targets are really down users will still see errors, and you want to be paged before they report it.
Take quiz
Returns 404 for every request
Shuts itself down
Redirects to Route 53
Routes to all targets anyway (fail open)
To avoid an outage caused by a faulty health check
To save on LCU charges
To force target replacement
To keep sticky cookies valid
31. How does ELB achieve high availability across Availability Zones?
ELB places a load balancer node in each Availability Zone you enable. DNS returns the IPs of all healthy nodes, so clients spread over them, and each node routes to targets.
flowchart LR C[Client] --> D["DNS lookup"] D --> N1["LB node AZ-A"] D --> N2["LB node AZ-B"] N1 --> T1["Targets AZ-A"] N1 -.cross-zone.-> T2["Targets AZ-B"] N2 --> T2 N2 -.cross-zone.-> T1
If an AZ has no healthy targets or its node fails, ELB stops returning that node's IP and traffic moves to the other zones. With cross-zone enabled the surviving nodes can also use targets in other zones. Enable at least two AZs (ALB requires this) and keep targets in each. Zonal shift in Route 53 ARC lets you drain a zone manually.
Take quiz
Two
One
Three
Four
Clients are told to retry manually
Its IP is removed from DNS responses
It is rebooted by the client
All traffic stops until you act
32. Why do you get a 502 Bad Gateway from an ALB?
A 502 means the ALB reached the target but got an invalid or no response. The usual causes:
- Target closed the connection before replying, often because its keep-alive timeout is shorter than the ALB idle timeout
- Malformed HTTP response or invalid headers
- HTTPS target group but the target fails the TLS handshake
- Lambda target returned a response in the wrong format or crashed
Check HTTPCode_ELB_502_Count and the access log's error_reason field. The most common fix is setting backend keep-alive higher than the ALB idle timeout, for example above 60 seconds, such as 65 in Node.js or Nginx.
To confirm, capture an access log line and compare elb_status_code with target_status_code. A 502 with a target status of - means the target never sent a valid response, which points to a closed connection or a crash rather than an application error.
Take quiz
Lower the ALB idle timeout to 1 second
Set backend keep-alive timeout above the ALB idle timeout
Disable health checks
Enable cross-zone balancing
No healthy targets are registered
The request timed out waiting for a connection
The target gave an invalid or no response
The client closed the connection
33. Why do you get a 503 Service Unavailable from an ALB?
A 503 means the ALB has no target to send the request to.
- The target group has no registered targets
- A listener rule forwards to an empty target group, for instance after an Auto Scaling group scaled to zero
- A Lambda target is being throttled
- In rare cases the ALB is still scaling during a very sharp spike
Check the target group's registered targets and the HTTPCode_ELB_503_Count metric. Note that targets which are merely unhealthy do not cause 503 when all of them fail, because the ALB fails open.
To tell it apart from an unhealthy-target problem, look at the target group's registered list first. An empty list means the cause is registration, such as a failed deployment or an Auto Scaling group with a desired capacity of zero, not the application itself.
Take quiz
A target returning a malformed header
A client closing early
A target group with no registered targets
A slow database query
HTTPCode_Target_3XX_Count
RequestCount
ProcessedBytes
HTTPCode_ELB_503_Count
34. Why do you get a 504 Gateway Timeout from an ALB?
A 504 means the ALB could not connect to the target in time, or the target did not respond before the idle timeout (60 seconds by default).
- Check security groups and NACLs allow the ALB to reach the target port
- Look at
TargetResponseTimeto spot slow endpoints - Investigate slow downstream calls such as databases or third-party APIs
- Raise the ALB idle timeout only for endpoints that truly need long processing
- Move long jobs to an asynchronous pattern with a queue
Raising the timeout hides slow code, so fix the cause first.
Remember that the ALB waits for a connection to the target for 10 seconds before giving up, which is a different clock from the idle timeout. A 504 within about 10 seconds usually means a network block, while one at around 60 seconds usually means a slow application.
Take quiz
10 seconds
350 seconds
30 minutes
60 seconds
Security groups allowing the ALB to the target port
The Route 53 TTL
The S3 bucket policy
The AMI version
35. How does idle timeout work on ALB and NLB?
The idle timeout is how long a connection can carry no data before the load balancer closes it.
| Load balancer | Default idle timeout |
| ALB | 60 s (configurable, 1 to 4000 s) |
| NLB TCP | 350 s (configurable for TCP listeners) |
| NLB UDP | 120 s |
For ALB, make sure backend keep-alive is longer than the idle timeout, otherwise the target may close a connection the ALB is about to reuse and you get 502s. For long-lived WebSockets or slow uploads, send heartbeats or TCP keepalives so the connection never sits idle.
Clients behind NAT devices can also drop idle flows earlier than the load balancer does, so a short keepalive interval, say every 30 seconds, is a safe default for long-lived sessions such as MQTT or WebSockets.
Take quiz
120 seconds
60 seconds
350 seconds
4000 seconds
Shorter
Longer
Exactly zero
It does not matter
36. Explain the internal working of Gateway Load Balancer?
GWLB inserts a fleet of inspection appliances into the traffic path without changing client or server configuration.
sequenceDiagram participant C as Client participant E as GWLB Endpoint participant G as GWLB participant A as Appliance participant S as App Server C->>E: Packet via route table E->>G: Forward over PrivateLink G->>A: GENEVE encapsulated (UDP 6081) A->>G: Inspected packet G->>E: Return E->>S: Deliver to destination
- Route tables (including an ingress route table on the internet gateway) send traffic to the GWLB endpoint
- The endpoint forwards it to the GWLB through PrivateLink
- GWLB picks an appliance using a 5-tuple flow hash and wraps the packet in GENEVE
- The appliance inspects, allows or drops, then returns it
- GWLB hands it back to the endpoint, which delivers it onward
The same appliance sees both directions of a flow, and health checks remove failed appliances from rotation. Appliances must understand GENEVE.
Take quiz
To reduce LCU billing
Stateful inspection needs the full conversation
To keep DNS TTL low
To allow Elastic IPs
A NAT gateway
An internet gateway alone
A GWLB endpoint
A Route 53 alias
37. How does an NLB preserve client IP addresses?
For instance targets, the NLB keeps the original client source IP by default, so the target sees the real address in the TCP or UDP packets. No header is needed.
For IP targets with TCP and TLS, preservation is off by default and targets see the NLB's private IP. You control it with the target group attribute preserve_client_ip.enabled.
One caveat is hairpinning: if a target connects to the NLB and the flow is routed back to that same target with the client IP preserved, the connection fails. Where preservation is off, enable Proxy Protocol v2 to pass the client details.
Security groups on the targets should therefore allow the real client ranges when preservation is on, because traffic no longer appears to come from the NLB. When preservation is off, allow the NLB's subnets instead.
Take quiz
lambda
alb
instance
None of them
TLS certificate validation
DNS resolution
Auto Scaling health checks
The connection, due to hairpinning
38. What is Proxy Protocol v2 and when should you use it with an NLB?
Proxy Protocol v2 is a binary header the NLB adds at the start of a TCP connection, carrying the original client and destination address and port. When the connection is routed through PrivateLink it also includes the VPC endpoint ID.
Use it when client IP preservation is not available or turned off, such as IP-type targets or services published via PrivateLink. You enable it in the target group attributes.
The application or proxy on the target must parse the header. If it does not, it will see garbage bytes and the connection fails, so enable it only after the backend (Nginx, HAProxy, your app) is configured for it.
Take quiz
The TLS private key
The Auto Scaling group name
The ALB rule priority
Original client connection details
The connection fails or shows garbage data
It is silently ignored
The NLB retries without it
The ALB takes over
39. How does SNI work on an ALB or NLB?
Server Name Indication (SNI) lets one listener serve several domains with different certificates. The client includes the host name in the TLS ClientHello, and the load balancer uses it to pick the matching certificate.
You attach a default certificate plus additional certificates to the HTTPS listener (ALB) or TLS listener (NLB). If no certificate matches, the default is used.
ALB chooses the best certificate for the client, preferring ECDSA over RSA when both match and the client supports it. The Classic Load Balancer does not support SNI, so each of its listeners holds a single certificate.
In practice, request one ACM certificate per domain or a certificate with several names, attach all of them to the listener, and test each host name with openssl s_client -servername. Old clients that do not send SNI will receive the default certificate.
Take quiz
TLS ClientHello
HTTP response header
DNS answer
TCP FIN
Application Load Balancer
Classic Load Balancer
Network Load Balancer with TLS listener
None, all support SNI
40. How do you implement blue/green deployments using ALB weighted target groups?
Run the old version (blue) and new version (green) in separate target groups and shift traffic using the forward action with weights.
aws elbv2 modify-listener --listener-arn $L --default-actions '[{ "Type":"forward", "ForwardConfig":{"TargetGroups":[ {"TargetGroupArn":"'$BLUE'","Weight":90}, {"TargetGroupArn":"'$GREEN'","Weight":10}]}}]'
- Deploy green and wait for healthy targets
- Send 10% of traffic to green and watch error and latency metrics
- Increase gradually to 100%
- Roll back instantly by setting blue to 100
Enable target group stickiness on the forward action if users must stay on one version during the shift.
Keep the blue fleet running until the green fleet has served full traffic through a normal peak, since removing it early takes away your instant rollback. After that, drain and scale blue down, and make green the new baseline for the next release.
Take quiz
Delete the ALB
Set the blue target group weight back to 100
Restart the listener
Disable health checks
Sends 90% to both groups
Blocks the green group
Sends about 10% of requests to the new target group
Sends all traffic to green
41. How can an ALB authenticate users with Cognito or OIDC?
You add an authenticate-cognito or authenticate-oidc action ahead of the forward action in an HTTPS listener rule. The ALB handles the login so your app does not need to.
- Unauthenticated user hits the ALB
- ALB redirects them to the identity provider
- After login the provider sends an authorization code back to the ALB
- ALB exchanges it for tokens, sets an
AWSELBAuthSessionCookie, and forwards the request
Targets receive user claims in x-amzn-oidc-data (a signed JWT), plus x-amzn-oidc-identity and x-amzn-oidc-accesstoken. Verify the JWT signature in the app. OnUnauthenticatedRequest can be authenticate, deny or allow.
Set the session timeout to match your security policy, since the ALB cookie lasts up to 7 days by default. Also register the ALB's /oauth2/idpresponse URL as an allowed callback in the identity provider, or the login round trip will fail.
Take quiz
Authorization-Basic
x-amz-cognito-id
x-amzn-oidc-data
X-Forwarded-User
HTTP
TCP
UDP
HTTPS
42. How does AWS WAF integrate with an ALB?
You associate a regional AWS WAF web ACL with the ALB. Requests are inspected before routing, and blocked ones never reach your targets.
- AWS managed rule groups for OWASP-style threats, bots and known bad inputs
- Rate-based rules to throttle abusive IPs
- IP set and geo match rules
- Custom rules on headers, URI, query string or body
WAF works with ALB but not with NLB, so for non-HTTP traffic you rely on security groups and NACLs. Enable WAF logging to see which rule blocked a request.
Start new rules in Count mode, review the logs for false positives, and only then switch to Block. This avoids blocking legitimate users while you tune managed rule groups.
Take quiz
Network Load Balancer
Gateway Load Balancer
All three
Application Load Balancer
Rate-based rule
Geo match rule
Managed SQL rule
Header size rule
43. How does an ALB route requests to Lambda functions?
Create a target group of type lambda, register the function, and forward a listener rule to it. The ALB invokes the function synchronously for each request.
- Grant permission to
elasticloadbalancing.amazonaws.comto invoke the function - ALB converts the HTTP request into a JSON event
- Function returns JSON with
statusCode,headers,bodyandisBase64Encoded - ALB converts it back into an HTTP response
def handler(event, context): return {"statusCode": 200, "headers": {"Content-Type": "text/html"}, "body": "<h1>Hello from Lambda</h1>", "isBase64Encoded": False}
Request and response payloads are limited to 1 MB, and health checks are off by default for Lambda target groups.
This is handy for small APIs, health pages or admin endpoints that do not justify a server. If clients send multiple values for one header or query parameter, enable multi-value headers on the target group so none are lost.
Take quiz
statusCode
httpMethod
requestId
targetArn
Asynchronously via SQS
Synchronously, once per request
Only on a schedule
Through an NLB
44. How does the AWS Load Balancer Controller work in EKS?
The AWS Load Balancer Controller runs inside the cluster, watches Kubernetes objects and creates ELB resources for them.
flowchart LR I[Ingress] --> C["LB Controller"] S["Service type LoadBalancer"] --> C C --> ALB[ALB] C --> NLB[NLB] ALB --> P[Pods] NLB --> P
- Ingress resources become an ALB with listener rules
- Service of type LoadBalancer with the controller's class becomes an NLB
target-type: ipregisters pod IPs directly, skipping NodePort and kube-proxy hopstarget-type: instancesends traffic to NodePorts on worker nodes
metadata: annotations: alb.ingress.kubernetes.io/scheme: internet-facing alb.ingress.kubernetes.io/target-type: ip
The controller needs IAM permissions, typically through IRSA or EKS Pod Identity.
Use IP mode in most clusters: it removes the extra hop through kube-proxy, lowers latency, and lets the ALB drain pods precisely during rolling updates when combined with pod readiness gates.
Take quiz
A Gateway Load Balancer
An Application Load Balancer
A CloudFront distribution
A Route 53 zone
Registers node public IPs
Disables health checks
Registers pod IPs directly with the target group
Creates a VPN
45. How does ECS dynamic port mapping work with an ALB?
With bridge networking you set the container's host port to 0 and ECS picks a free ephemeral port for each task. ECS then registers instance-ID:port with the ALB target group.
This lets several copies of the same service run on one EC2 instance, each on a different host port, while the ALB still reaches all of them.
The instance security group must allow the ephemeral port range from the ALB security group. With awsvpc mode each task gets its own ENI and IP, so you use an ip target type and a fixed container port instead.
The target group health checks then run against the dynamically assigned port, so keep the health check port set to traffic-port rather than a fixed number. Otherwise every task would look unhealthy.
Take quiz
80
443
0
65535
lambda
alb
instance with fixed port 0
ip
46. How does mutual TLS work on an ALB?
With mutual TLS (mTLS) the client must present a certificate as well as the server. You enable it on an HTTPS listener and give it a trust store, a CA certificate bundle kept in S3, with an optional revocation list.
| Mode | Behaviour |
| Verify | ALB validates the client certificate and passes its details to the target in headers |
| Passthrough | ALB forwards the certificate in a header without validating, so the app decides |
Verify mode is the safer default for APIs and B2B integrations, since invalid clients are rejected at the edge before they cost you any backend capacity.
Certificate details arrive in headers such as X-Amzn-Mtls-Clientcert-Subject, which the app can use for authorisation, for example mapping a certificate subject to a customer account.
Take quiz
An IAM role
A security group
CloudTrail
A trust store backed by S3
Verify
Passthrough
Offload
Redirect
47. How does slow start mode work in ALB?
Slow start mode gives a newly registered target a gradually increasing share of requests during a warm-up window, instead of its full share immediately. The window is 30 to 900 seconds and it is off by default.
It protects apps that need time to warm up, such as JVMs that must JIT-compile code or services filling caches. Without it, a fresh target can be flooded and fail health checks.
It works only with the round robin algorithm. It is not supported with least outstanding requests or weighted random. A target leaves slow start when the window ends or it becomes unhealthy.
Choose a duration that matches your measured warm-up time. A value that is too short defeats the purpose, while a very long one leaves new capacity underused when you scale out during a spike.
Take quiz
30 to 900 seconds
1 to 10 seconds
1 to 24 hours
300 to 3600 seconds
Least outstanding requests
Round robin
Weighted random
Flow hash
48. How do you troubleshoot unhealthy targets in ELB?
Start from the reason code in the target group's Targets tab, then work through the network and app.
| Reason code | Likely cause |
| Target.ResponseCodeMismatch | Health path returned a code outside the success matcher |
| Target.Timeout | No reply in time: blocked by security group, NACL or slow app |
| Target.FailedHealthChecks | Connection refused or TLS failure |
- Confirm the app is listening on the health check port and interface
- Allow the ALB security group to the health check port
- Curl the health path from another host in the VPC
- Check the matcher (a redirect 301 fails if only 200 is accepted)
- Allow enough time for startup versus thresholds and grace period
If everything looks right but targets still fail, compare the health check path with what users hit. A path that needs authentication or a database call can fail only under the load balancer's anonymous request, so use a dedicated lightweight endpoint.
Take quiz
The security group blocked the check
Target answered with a code not in the success matcher
The target was deregistered
DNS failed to resolve
The ALB follows the redirect
The target is healthy
The target is marked unhealthy
The check is skipped
49. How do you enable and use ALB access logs?
Access logs are optional and off by default. Turn them on in the load balancer attributes and choose an S3 bucket.
- Create an S3 bucket in the same Region
- Add a bucket policy that allows ELB log delivery
- Enable access logs on the ALB
- Logs are delivered about every five minutes as compressed files
Each line records the time, client IP and port, target, three processing times, ELB and target status codes, the request line, user agent, TLS cipher and an error reason when relevant.
Query them with Amazon Athena to find slow endpoints or 5xx spikes. ALB also offers separate connection logs for TLS details.
Logs can hold sensitive paths and IPs, so encrypt the bucket and set a lifecycle rule that expires old objects. Partition the Athena table by date to keep query costs low.
Take quiz
CloudWatch Metrics only
The target instances
An Amazon S3 bucket
AWS Config
AWS Glue DataBrew only
Amazon SES
AWS Direct Connect
Amazon Athena
50. What is the difference between ELB and Route 53 load balancing?
ELB balances live connections or requests across healthy targets inside a Region. Route 53 balances at the DNS layer by returning different answers to name lookups.
| Aspect | ELB | Route 53 |
| Layer | Connections and requests (L4/L7) | DNS responses |
| Scope | Within a Region, across AZs | Across Regions or endpoints |
| Failover speed | Seconds, health checks per target | Bound by DNS TTL and resolver caching |
| Policies | Algorithms, rules, stickiness | Weighted, latency, failover, geolocation |
They work together: Route 53 latency or failover records point users to the nearest healthy Region, and an ELB in each Region balances across its targets.
Because resolvers cache answers for the TTL, a Route 53 failover can take minutes to take effect for some users, while an ELB stops sending traffic to a failed target within a few health check intervals. Keep TTLs low, such as 60 seconds, on records used for failover.