📖 Scenario: You are working as a cloud engineer for a company that wants to understand different types of load balancers available in Google Cloud Platform (GCP). They want a simple programmatic way to compare the main types of load balancers by their key features.
🎯 Goal: Create a Python dictionary that holds the main GCP load balancer types as keys and their key features as values. Then add a configuration variable to select a load balancer type. Next, write code to extract the features of the selected load balancer. Finally, complete the code by adding a summary dictionary entry for all load balancers.
📋 What You'll Learn
Create a dictionary called load_balancers with these exact keys: 'HTTP(S) Load Balancer', 'TCP Proxy Load Balancer', 'SSL Proxy Load Balancer', 'Network Load Balancer'
Each key must map to a list of exactly these features (strings):
Create a variable called selected_lb and set it to the string 'HTTP(S) Load Balancer'
Write code to get the features list for the selected_lb from load_balancers and store it in a variable called features
Add a new dictionary entry to load_balancers with key 'Summary' and value as a list of all load balancer keys except 'Summary'
💡 Why This Matters
🌍 Real World
Cloud engineers often need to compare and document different cloud services to choose the right one for their applications.
💼 Career
Understanding load balancer types and their features is essential for designing scalable and reliable cloud architectures.
Progress0 / 4 steps
1
Create the load balancers dictionary
Create a dictionary called load_balancers with these exact keys and values: 'HTTP(S) Load Balancer' mapped to ['Global', 'Layer 7', 'Supports HTTP and HTTPS'], 'TCP Proxy Load Balancer' mapped to ['Global', 'Layer 4', 'TCP traffic only'], 'SSL Proxy Load Balancer' mapped to ['Global', 'Layer 4', 'SSL traffic only'], and 'Network Load Balancer' mapped to ['Regional', 'Layer 4', 'TCP and UDP traffic'].
GCP
Hint
Use a Python dictionary with the exact keys and list values as specified.
2
Add selected load balancer variable
Create a variable called selected_lb and set it to the string 'HTTP(S) Load Balancer'.
GCP
Hint
Assign the exact string to the variable selected_lb.
3
Extract features of selected load balancer
Write code to get the features list for the load balancer stored in selected_lb from the load_balancers dictionary and store it in a variable called features.
GCP
Hint
Use dictionary access with the variable selected_lb as the key.
4
Add summary entry to load balancers dictionary
Add a new dictionary entry to load_balancers with the key 'Summary' and the value as a list of all load balancer keys except 'Summary' itself.
GCP
Hint
Use a list comprehension to get all keys except 'Summary' and assign it to load_balancers['Summary'].
Practice
(1/5)
1. Which GCP load balancer type is best suited for distributing HTTP and HTTPS traffic globally with SSL termination?
easy
A. TCP Proxy Load Balancer
B. Internal Load Balancer
C. Network Load Balancer
D. HTTP(S) Load Balancer
Solution
Step 1: Understand the traffic type
HTTP and HTTPS traffic require Layer 7 (application layer) handling with SSL termination.
Step 2: Match load balancer capabilities
HTTP(S) Load Balancer supports global distribution and SSL termination for web traffic.
5. You have a multi-region web app serving HTTP and HTTPS traffic with backend services in multiple zones. You want to minimize latency and provide automatic failover. Which GCP load balancer type should you choose and why?
hard
A. Network Load Balancer because it supports UDP and TCP globally
B. Internal Load Balancer because it routes traffic inside the VPC
C. HTTP(S) Load Balancer because it offers global load balancing with SSL termination and health checks
D. TCP Proxy Load Balancer because it handles TCP traffic with SSL offloading
Solution
Step 1: Analyze requirements for multi-region HTTP/HTTPS app
Needs global load balancing, SSL termination, low latency, and failover.
Step 2: Match load balancer features
HTTP(S) Load Balancer supports global distribution, SSL termination, health checks, and automatic failover.
Step 3: Exclude other options
Network Load Balancer is regional and lacks SSL termination; Internal Load Balancer is internal-only; TCP Proxy is for TCP, not HTTP/HTTPS.
Final Answer:
HTTP(S) Load Balancer because it offers global load balancing with SSL termination and health checks -> Option C