0
0
AWScloud~10 mins

Application Load Balancer (ALB) in AWS - Step-by-Step Execution

Choose your learning style9 modes available
Process Flow - Application Load Balancer (ALB)
Client sends HTTP request
ALB receives request
ALB evaluates listener rules
Select target group based on rules
Forward request to healthy target instance
Target instance processes request and responds
ALB sends response back to client
The ALB receives client requests, checks rules to decide which server group to send to, forwards the request to a healthy server, and returns the response to the client.
Execution Sample
AWS
resource "aws_lb" "example" {
  name               = "example-alb"
  internal           = false
  load_balancer_type = "application"
  subnets            = ["subnet-123", "subnet-456"]
}
This code creates an Application Load Balancer named 'example-alb' in two subnets, ready to route HTTP requests.
Process Table
StepActionInput/ConditionResult/Output
1Client sends HTTP requestRequest to ALB DNSRequest arrives at ALB
2ALB listener receives requestListener on port 80 activeListener accepts request
3ALB evaluates listener rulesRule: path /api/* -> target group ARequest matches /api/* rule
4ALB selects target groupTarget group A has 3 healthy instancesTarget group A chosen
5ALB forwards requestSelect healthy instance from target group ARequest sent to instance i-12345
6Instance processes requestInstance i-12345 receives requestInstance returns HTTP 200 response
7ALB sends response to clientResponse from instanceClient receives HTTP 200 response
8EndNo more requestsWaiting for next client request
💡 Execution stops after response is sent back to client and ALB waits for new requests.
Status Tracker
VariableStartAfter Step 3After Step 4After Step 5Final
Request Path//api/users/api/users/api/users/api/users
Selected Target GroupNoneNoneTarget Group ATarget Group ATarget Group A
Target InstanceNoneNoneNonei-12345i-12345
Response StatusNoneNoneNoneNone200 OK
Key Moments - 3 Insights
How does the ALB decide which target group to send the request to?
The ALB checks listener rules against the request path or host. In the execution table at Step 3, the request path '/api/users' matches the rule '/api/*', so target group A is selected at Step 4.
What happens if no target instances are healthy?
If no healthy targets exist in the selected target group, the ALB cannot forward the request, resulting in an error response. This is not shown in the current execution but would stop forwarding at Step 5.
Why does the ALB wait after sending the response?
After sending the response (Step 7), the ALB waits for new client requests to handle. This is shown in Step 8 where it is idle, ready for the next request.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution table, at which step does the ALB select the target group?
AStep 2
BStep 4
CStep 6
DStep 7
💡 Hint
Check the 'Action' column for 'ALB selects target group' in the execution table.
According to the variable tracker, what is the 'Response Status' after Step 7?
ANone
B404 Not Found
C200 OK
D500 Internal Server Error
💡 Hint
Look at the 'Response Status' row under the 'Final' column in the variable tracker.
If the request path was '/home' instead of '/api/users', how would the selected target group change?
ATarget Group A would still be selected
BNo target group would be selected
CA different target group would be selected if rules exist
DThe ALB would forward to all target groups
💡 Hint
Refer to Step 3 in the execution table where rules are matched based on the request path.
Concept Snapshot
Application Load Balancer (ALB):
- Receives client HTTP/HTTPS requests
- Uses listeners and rules to route requests
- Forwards requests to healthy targets in target groups
- Supports path and host-based routing
- Returns responses from targets back to clients
- Automatically handles scaling and health checks
Full Transcript
An Application Load Balancer (ALB) receives HTTP requests from clients. It listens on specified ports and evaluates rules to decide which target group should handle the request. The ALB forwards the request to a healthy instance in the chosen target group. The instance processes the request and sends back a response. The ALB then returns this response to the client. After completing a request, the ALB waits for new incoming requests. This process ensures efficient and reliable routing of web traffic to backend servers.