Bird
Raised Fist0
AWScloud~10 mins

Network Load Balancer (NLB) in AWS - Step-by-Step Execution

Choose your learning style10 modes available
Process Flow - Network Load Balancer (NLB)
Client sends request
↓
NLB receives request
↓
NLB selects target based on flow hash
↓
NLB forwards request to target instance
↓
Target instance processes request and responds
↓
NLB forwards response back to client
The Network Load Balancer receives client requests, selects a target instance using flow hashing, forwards the request, and then sends the response back to the client.
Execution Sample
AWS
resource "aws_lb" "nlb" {
  name               = "example-nlb"
  internal           = false
  load_balancer_type = "network"
  subnets            = ["subnet-12345", "subnet-67890"]
}

resource "aws_lb_target_group" "tg" {
  name     = "example-tg"
  port     = 80
  protocol = "TCP"
  vpc_id   = "vpc-abcde"
}

resource "aws_lb_listener" "listener" {
  load_balancer_arn = aws_lb.nlb.arn
  port              = 80
  protocol          = "TCP"
  default_action {
    type             = "forward"
    target_group_arn = aws_lb_target_group.tg.arn
  }
}
This code creates a Network Load Balancer, a target group, and a listener that forwards TCP traffic on port 80 to the target group.
Process Table
StepActionNLB StateTarget Group StateClient Experience
1Client sends TCP request to NLB on port 80Idle, waiting for requestTargets healthyRequest sent
2NLB receives requestProcessing requestTargets healthyRequest received by NLB
3NLB selects target using flow hashSelected target instanceTarget selectedRequest routed to target
4NLB forwards request to target instanceForwardingTarget processing requestRequest processing started
5Target instance processes and respondsWaiting for responseTarget sends responseResponse generated
6NLB forwards response back to clientIdleTargets healthyClient receives response
7Client connection closed or kept aliveIdleTargets healthyConnection ends or persists
💡 Request-response cycle completed; NLB ready for next request
Status Tracker
VariableStartAfter Step 3After Step 6Final
NLB StateIdleSelected target instanceIdleIdle
Target Group StateTargets healthyTarget selectedTargets healthyTargets healthy
Client ExperienceRequest sentRequest routed to targetClient receives responseConnection ends or persists
Key Moments - 3 Insights
How does the NLB decide which target instance to send the request to?
The NLB uses a flow hash algorithm to select a target instance, ensuring requests from the same client IP and port go to the same target. This is shown in execution_table step 3.
Why does the NLB stay 'Idle' after forwarding the response?
After completing the request-response cycle, the NLB returns to idle state waiting for new requests, as seen in execution_table step 6 and 7.
What happens if a target instance is unhealthy?
The NLB excludes unhealthy targets from selection, so requests are only forwarded to healthy targets, keeping client experience smooth. This is implied in variable_tracker where targets remain healthy.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table, at which step does the NLB select the target instance?
AStep 2
BStep 3
CStep 4
DStep 5
💡 Hint
Check the 'Action' column in execution_table row for step 3 where target selection happens.
According to variable_tracker, what is the NLB state after step 6?
AProcessing request
BSelected target instance
CIdle
DForwarding
💡 Hint
Look at the 'NLB State' row under 'After Step 6' in variable_tracker.
If a target becomes unhealthy, how would the client experience change in the execution_table?
AClient receives response slower or errors
BNLB state changes to 'Error'
CTarget group state shows 'Targets healthy'
DClient request is dropped immediately
💡 Hint
Consider how unhealthy targets affect response time and client experience in execution_table.
Concept Snapshot
Network Load Balancer (NLB) forwards TCP/UDP traffic at connection level.
Uses flow hash to select healthy targets.
Handles millions of requests with low latency.
Supports static IP and preserves client IP.
Ideal for extreme performance and scaling.
Full Transcript
A Network Load Balancer (NLB) receives client requests on a TCP port. It uses a flow hash algorithm to select a healthy target instance from its target group. The NLB forwards the request to the selected target, which processes it and sends back a response. The NLB then forwards the response to the client. After completing the request-response cycle, the NLB returns to idle state, ready for new requests. Unhealthy targets are excluded from selection to maintain smooth client experience.

Practice

(1/5)
1. What is the primary purpose of an AWS Network Load Balancer (NLB)?
easy
A. To efficiently distribute TCP/UDP traffic at the connection level
B. To manage HTTP requests with advanced routing rules
C. To store and retrieve data in a scalable way
D. To provide a user interface for managing AWS resources

Solution

  1. Step 1: Understand NLB's traffic handling

    NLB works at the connection level and handles TCP/UDP traffic efficiently.
  2. Step 2: Compare with other AWS services

    Unlike Application Load Balancer, NLB does not manage HTTP features but focuses on low latency and high throughput for TCP/UDP.
  3. Final Answer:

    To efficiently distribute TCP/UDP traffic at the connection level -> Option A
  4. Quick Check:

    NLB purpose = TCP/UDP load balancing [OK]
Hint: NLB handles TCP/UDP, not HTTP features [OK]
Common Mistakes:
  • Confusing NLB with Application Load Balancer
  • Thinking NLB manages HTTP routing
  • Assuming NLB stores data
2. Which of the following is a valid characteristic of an AWS Network Load Balancer (NLB)?
easy
A. Only supports HTTP and HTTPS protocols
B. Requires manual scaling for high traffic
C. Automatically modifies HTTP headers
D. Supports static IP addresses for the load balancer

Solution

  1. Step 1: Identify NLB features

    NLB supports static IP addresses, which is useful for fixed IP requirements.
  2. Step 2: Eliminate incorrect options

    NLB does not only support HTTP/HTTPS (it supports TCP/UDP), does not modify HTTP headers, and scales automatically.
  3. Final Answer:

    Supports static IP addresses for the load balancer -> Option D
  4. Quick Check:

    Static IP support = true for NLB [OK]
Hint: NLB supports static IPs, unlike ALB [OK]
Common Mistakes:
  • Thinking NLB only supports HTTP/HTTPS
  • Assuming NLB modifies HTTP headers
  • Believing NLB requires manual scaling
3. Given an NLB configured to balance TCP traffic across three targets, what happens if one target becomes unhealthy?
medium
A. NLB stops sending traffic to the unhealthy target and continues with healthy ones
B. NLB sends traffic evenly to all targets regardless of health
C. NLB shuts down until the unhealthy target recovers
D. NLB redirects traffic to a backup Application Load Balancer

Solution

  1. Step 1: Understand NLB health checks

    NLB performs health checks and routes traffic only to healthy targets.
  2. Step 2: Analyze behavior on unhealthy target

    If a target is unhealthy, NLB excludes it from routing until it recovers.
  3. Final Answer:

    NLB stops sending traffic to the unhealthy target and continues with healthy ones -> Option A
  4. Quick Check:

    Health checks exclude unhealthy targets [OK]
Hint: NLB routes only to healthy targets [OK]
Common Mistakes:
  • Assuming NLB sends traffic to unhealthy targets
  • Thinking NLB stops completely on failure
  • Believing NLB redirects to ALB automatically
4. You configured an NLB but notice it is not distributing UDP traffic as expected. What is the most likely cause?
medium
A. Health checks are disabled for the target group
B. The target group is configured for TCP instead of UDP
C. NLB does not support UDP traffic
D. NLB requires HTTP listeners for UDP traffic

Solution

  1. Step 1: Check protocol configuration

    NLB supports UDP, but the target group must be set to UDP to handle UDP traffic.
  2. Step 2: Identify misconfiguration

    If the target group is set to TCP, UDP traffic won't be routed correctly.
  3. Final Answer:

    The target group is configured for TCP instead of UDP -> Option B
  4. Quick Check:

    Target group protocol must match traffic [OK]
Hint: Match target group protocol to traffic type [OK]
Common Mistakes:
  • Thinking NLB does not support UDP
  • Ignoring target group protocol settings
  • Assuming health checks cause traffic issues
5. You need to design a highly scalable system that requires static IP addresses and low latency for millions of TCP connections. Which AWS load balancer should you choose and why?
hard
A. Gateway Load Balancer, because it manages HTTP and TCP traffic with static IPs
B. Application Load Balancer, because it supports HTTP routing and static IPs
C. Network Load Balancer, because it supports static IPs and handles millions of TCP connections with low latency
D. Classic Load Balancer, because it is the newest and fastest option

Solution

  1. Step 1: Identify requirements

    The system needs static IPs, low latency, and support for millions of TCP connections.
  2. Step 2: Match requirements to load balancer features

    NLB supports static IPs, is designed for extreme scalability, and handles TCP traffic efficiently with low latency.
  3. Step 3: Eliminate incorrect options

    ALB focuses on HTTP, Classic LB is older and less scalable, Gateway LB is for network appliances, not general TCP load balancing.
  4. Final Answer:

    Network Load Balancer, because it supports static IPs and handles millions of TCP connections with low latency -> Option C
  5. Quick Check:

    Static IP + TCP + scalability = NLB [OK]
Hint: For static IP and TCP scale, choose NLB [OK]
Common Mistakes:
  • Choosing ALB for TCP static IP needs
  • Confusing Classic LB as newest
  • Assuming Gateway LB handles general TCP load balancing
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard