📖 Scenario: You are working as a cloud architect for a company that needs to set up load balancing for their web applications. They want to understand when to use an Application Load Balancer (ALB) versus a Network Load Balancer (NLB) in AWS.Your task is to create a simple decision helper in Python that helps decide which load balancer to use based on the application requirements.
🎯 Goal: Build a Python script that stores application requirements and uses simple logic to decide whether to use an ALB or NLB.
📋 What You'll Learn
Create a dictionary with application requirements
Add a configuration variable for traffic type
Write logic to decide ALB or NLB based on traffic type
Output the final decision as a variable
💡 Why This Matters
🌍 Real World
Choosing the right AWS load balancer is important for application performance and cost optimization.
💼 Career
Cloud architects and engineers often need to decide between ALB and NLB based on application needs.
Progress0 / 4 steps
1
Create application requirements dictionary
Create a dictionary called app_requirements with these exact entries: 'protocol': 'HTTP', 'port': 80, 'target_type': 'instance'
AWS
Hint
Use curly braces to create a dictionary with keys and values exactly as shown.
2
Add traffic type configuration
Add a variable called traffic_type and set it to the string 'HTTP'
AWS
Hint
Assign the string 'HTTP' to the variable traffic_type.
3
Write decision logic for load balancer
Write an if statement that sets a variable load_balancer_choice to 'ALB' if traffic_type is 'HTTP', otherwise set it to 'NLB'
AWS
Hint
Use an if-else statement to assign the correct load balancer choice based on traffic_type.
4
Set final decision variable
Add a variable called final_decision and set it equal to load_balancer_choice
AWS
Hint
Assign the variable final_decision to the value of load_balancer_choice.
Practice
(1/5)
1. Which AWS load balancer should you choose if you want to route HTTP requests based on URL paths?
easy
A. Gateway Load Balancer
B. Network Load Balancer (NLB)
C. Classic Load Balancer
D. Application Load Balancer (ALB)
Solution
Step 1: Understand ALB routing capabilities
ALB can route HTTP/HTTPS traffic based on content like URL paths or host headers.
Step 2: Compare with NLB capabilities
NLB routes at the network level and does not inspect HTTP content for routing.
Final Answer:
Application Load Balancer (ALB) -> Option D
Quick Check:
Content-based routing = ALB [OK]
Hint: Use ALB for HTTP content routing, not NLB [OK]
Common Mistakes:
Choosing NLB for HTTP content routing
Confusing Classic Load Balancer with ALB
Assuming NLB can inspect HTTP headers
2. Which protocol is primarily supported by Network Load Balancer (NLB) for fast, low-latency traffic?
easy
A. TCP/UDP
B. FTP
C. HTTP/HTTPS
D. SMTP
Solution
Step 1: Identify NLB protocol support
NLB is designed to handle TCP and UDP traffic for fast, low-latency connections.
Step 2: Exclude HTTP/HTTPS protocols
HTTP/HTTPS are application layer protocols handled by ALB, not NLB.
3. You have a web application that requires routing requests based on hostnames and needs SSL termination. Which load balancer will correctly handle this?
medium
A. Network Load Balancer (NLB)
B. Gateway Load Balancer
C. Application Load Balancer (ALB)
D. Classic Load Balancer
Solution
Step 1: Check hostname-based routing support
ALB supports routing based on hostnames, which is needed here.
Step 2: Confirm SSL termination capability
ALB can terminate SSL connections, simplifying certificate management.
Final Answer:
Application Load Balancer (ALB) -> Option C
Quick Check:
Hostname routing + SSL termination = ALB [OK]
Hint: SSL termination and hostname routing need ALB [OK]
Routing based on URL paths requires application layer inspection, which only ALB supports.
Final Answer:
NLB cannot inspect HTTP content for routing decisions -> Option B
Quick Check:
NLB lacks HTTP content inspection [OK]
Hint: NLB works at network layer, no HTTP content routing [OK]
Common Mistakes:
Thinking NLB supports HTTP path routing
Confusing TCP support with HTTP inspection
Assuming SSL certs fix routing issues
5. You need to design a system that handles millions of TCP connections with very low latency and also routes HTTP requests based on URL paths. What is the best load balancer setup?
hard
A. Use NLB for TCP connections and ALB for HTTP routing
B. Use only an Application Load Balancer (ALB) for all traffic
C. Use only a Network Load Balancer (NLB) for all traffic
D. Use Classic Load Balancer for both TCP and HTTP traffic
Solution
Step 1: Identify requirements for TCP and HTTP traffic
Millions of TCP connections need low latency, best handled by NLB. HTTP routing by URL paths requires ALB.
Step 2: Combine load balancers for best performance
Use NLB for TCP traffic and ALB for HTTP traffic to meet both needs efficiently.
Final Answer:
Use NLB for TCP connections and ALB for HTTP routing -> Option A
Quick Check:
TCP low latency + HTTP routing = NLB + ALB [OK]
Hint: Combine NLB for TCP and ALB for HTTP routing [OK]
Common Mistakes:
Using only ALB for TCP traffic causing latency
Using only NLB missing HTTP routing features
Choosing Classic Load Balancer for modern needs
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.