Bird
Raised Fist0
GCPcloud~10 mins

TCP/UDP Load Balancer (Layer 4) in GCP - Interactive Code Practice

Choose your learning style10 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to specify the protocol for the load balancer.

GCP
load_balancer_config = {
  "protocol": "[1]",
  "port": 80
}
Drag options to blanks, or click blank then click option'
ATCP
BHTTP
CHTTPS
DFTP
Attempts:
3 left
๐Ÿ’ก Hint
Common Mistakes
Choosing HTTP or HTTPS instead of TCP
Confusing Layer 4 with Layer 7 protocols
2fill in blank
medium

Complete the code to define the backend service type for TCP/UDP load balancing.

GCP
backend_service = {
  "type": "[1]",
  "health_check": "tcp_health_check"
}
Drag options to blanks, or click blank then click option'
AHTTPS
BHTTP
CSSL
DTCP
Attempts:
3 left
๐Ÿ’ก Hint
Common Mistakes
Using HTTP or HTTPS as backend service type
Mixing SSL with TCP backend service type
3fill in blank
hard

Fix the error in the health check configuration for TCP load balancer.

GCP
health_check = {
  "type": "[1]",
  "port": 443
}
Drag options to blanks, or click blank then click option'
AHTTP
BHTTPS
CTCP
DSSL
Attempts:
3 left
๐Ÿ’ก Hint
Common Mistakes
Using HTTP or HTTPS health check for TCP load balancer
Setting incorrect port for health check
4fill in blank
hard

Fill both blanks to configure the forwarding rule for a TCP load balancer.

GCP
forwarding_rule = {
  "loadBalancingScheme": "[1]",
  "portRange": "[2]"
}
Drag options to blanks, or click blank then click option'
AEXTERNAL
BINTERNAL
C80-80
D443-443
Attempts:
3 left
๐Ÿ’ก Hint
Common Mistakes
Using INTERNAL scheme for public load balancer
Setting wrong port range that doesn't match backend service
5fill in blank
hard

Fill all three blanks to define the backend instance group and balancing mode.

GCP
backend = {
  "group": "[1]",
  "balancingMode": "[2]",
  "capacityScaler": [3]
}
Drag options to blanks, or click blank then click option'
A"projects/my-project/zones/us-central1-a/instanceGroups/my-group"
B"UTILIZATION"
C1.0
D"RATE"
Attempts:
3 left
๐Ÿ’ก Hint
Common Mistakes
Using short or incorrect instance group path
Choosing RATE balancing mode when UTILIZATION is expected
Setting capacityScaler to invalid values

Practice

(1/5)
1. What is the primary function of a TCP/UDP Load Balancer in GCP?
easy
A. Store and cache static website content for faster delivery
B. Analyze HTTP headers to route requests based on URL paths
C. Encrypt data packets before sending them to clients
D. Distribute incoming TCP or UDP traffic evenly across backend servers

Solution

  1. Step 1: Understand Layer 4 Load Balancing

    TCP/UDP Load Balancers operate at Layer 4, handling raw TCP or UDP traffic without inspecting application data.
  2. Step 2: Identify the main role

    The main role is to distribute incoming network traffic evenly across multiple backend servers to balance load and improve availability.
  3. Final Answer:

    Distribute incoming TCP or UDP traffic evenly across backend servers -> Option D
  4. Quick Check:

    Layer 4 Load Balancer = Traffic distribution [OK]
Hint: Layer 4 means TCP/UDP traffic distribution only [OK]
Common Mistakes:
  • Confusing Layer 4 with Layer 7 load balancing
  • Thinking it inspects HTTP headers
  • Assuming it caches content
2. Which GCP component is essential to define where TCP/UDP Load Balancer sends traffic?
easy
A. Cloud Storage Bucket
B. Forwarding Rule
C. Cloud Pub/Sub Topic
D. Cloud SQL Instance

Solution

  1. Step 1: Identify GCP components for Load Balancing

    Forwarding rules in GCP specify the IP address, port, and protocol that the load balancer listens on.
  2. Step 2: Understand traffic routing

    Forwarding rules direct incoming TCP/UDP traffic to the backend service or instance group.
  3. Final Answer:

    Forwarding Rule -> Option B
  4. Quick Check:

    Forwarding Rule = Traffic entry point [OK]
Hint: Forwarding Rule directs traffic to backends [OK]
Common Mistakes:
  • Choosing unrelated services like Cloud Storage
  • Confusing Pub/Sub with load balancing
  • Selecting Cloud SQL which is a database
3. Given a TCP Load Balancer with 3 backend instances, if 300 connections arrive evenly, how many connections does each instance handle?
medium
A. 100 connections
B. 300 connections
C. 150 connections
D. 50 connections

Solution

  1. Step 1: Understand even distribution

    The load balancer distributes connections evenly across all backend instances.
  2. Step 2: Calculate connections per instance

    300 connections divided by 3 instances equals 100 connections per instance.
  3. Final Answer:

    100 connections -> Option A
  4. Quick Check:

    300 รท 3 = 100 [OK]
Hint: Divide total connections by backend count [OK]
Common Mistakes:
  • Multiplying instead of dividing
  • Ignoring even distribution assumption
  • Choosing total connections as answer
4. You configured a TCP Load Balancer but backend instances are not receiving traffic. What is a common misconfiguration to check?
medium
A. Backend instances lack proper health checks
B. Forwarding rule uses HTTP protocol instead of TCP
C. Backend instances are in different cloud provider
D. Load balancer IP is not public

Solution

  1. Step 1: Check health checks configuration

    Load balancer only sends traffic to healthy backends. Missing or failing health checks cause no traffic routing.
  2. Step 2: Verify backend health status

    Ensure health checks are properly configured and passing for backend instances.
  3. Final Answer:

    Backend instances lack proper health checks -> Option A
  4. Quick Check:

    Health checks enable traffic routing [OK]
Hint: Always verify backend health checks first [OK]
Common Mistakes:
  • Assuming protocol mismatch blocks traffic
  • Ignoring health check failures
  • Thinking IP must be public for internal load balancer
5. You want to design a highly available TCP Load Balancer in GCP that handles millions of connections. Which combination ensures scalability and fault tolerance?
hard
A. Use a global HTTP(S) Load Balancer with TCP backend services
B. Deploy multiple zonal TCP Load Balancers without health checks to reduce latency
C. Use a single regional TCP Load Balancer with multiple backend instance groups and health checks
D. Configure a single backend instance with autoscaling but no load balancer

Solution

  1. Step 1: Understand GCP TCP Load Balancer types

    Regional TCP Load Balancers distribute traffic across multiple backend instance groups within a region, supporting health checks and autoscaling.
  2. Step 2: Evaluate scalability and fault tolerance

    Multiple backend groups with health checks ensure traffic only goes to healthy instances, enabling fault tolerance and scaling to millions of connections.
  3. Final Answer:

    Use a single regional TCP Load Balancer with multiple backend instance groups and health checks -> Option C
  4. Quick Check:

    Regional LB + backends + health checks = scalable & fault tolerant [OK]
Hint: Regional LB + health checks = scalable, fault tolerant [OK]
Common Mistakes:
  • Ignoring health checks reduces reliability
  • Using HTTP(S) LB for TCP traffic is incorrect
  • Single backend instance limits scalability
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