TCP Loadbalancer with Google Cloud (GCP)

Girish V P
ADIBI Technologies, Basavanagudi, Blore.
3 min readJan 12, 2019

A Google Cloud Platform (GCP ) TCP Load Balancing is used to distribute the sessions based on incoming IP protocol data, such as address, port, and protocol type. TCP Load Balancing is a regional, non-proxied and a IP forwarding mechanism.

Prerequisite: We create two Centos Linux nodes configured as web servers. Follow this document to configure a web server. You can create index.html with different content for each node so that you can easily identify loadbalancer redirects request to both node while you refresh the web browser with load balance IP address. Before you proceed further, access both nodes from the internet and make sure that they are working perfectly. Create a health check. Follow beginning of the document. Below is the screen shot of VM instances list.

The Experiment: Setting TCP Loadbalancer involved following steps,

  1. Fulfill the prerequisite ( Above steps)
  2. Create TCP LB
  3. Backend configuration for TCP LB
  4. Frontend configuration for TCP LB

2) Create TCP LB: Click The Navigation Menu and then Load balancing from Networking service.

Under TCP Load Balancing, click Start Configuration.

Follow the options below and Click Continue

3) Backend Configuration for LB : Select both nodes and health check like below.

4) Frontend Configuration for LB: Enter a name and port 80 like below

Testing the Configuration

Once TCP load balancer is created note down the public IP address and use the same IP address in the web browser to access web server. Each time you refresh the web browser you can see request is redirected to different node.

Below is the output of netstat command

Disclaimer: This experiment is accomplished in test environment. You are requested to verify your setup thoroughly before you implement in a production environment. Some of the screenshots may not reflect exactly as the original GCP web console due to mangled copying and joining of multiple screenshots to form a single one. You may have to refer the original GCP console.

--

--