In Edit Backend Service for GCP, what's the difference between "Protocol" and "Named port" and "Port numbers"?

Viewed 1880

Coming from an AWS background, I'm a bit confused.

I need traffic to come from https://dev.mydomain.co to be served on port 3000 on my compute instance and traffic from https://api.mydomain.co to be served on port 3001.

How do I achieve this with GCP Load Balancing?

  1. Does "Protocol" mean the protocol used to receive traffic from the Load Balancer? If so, how do we set it to HTTP?
  2. What does "Named port" do? Where do I add a "Named port" if it is a key-value map?
  3. And finally, what does "Port numbers" mean? Are they the ports that the backend service will use to contact my Compute Engine instance?

Thanks in advance!

Edit Backend Service screenshot

1 Answers

To configure load balancing for your configuration, create two backend services. One for port 3000 and the other for port 3001.

Configuring GCP load balancers are not difficult. You need to understand the concepts of:

  • Backends. Backends are built from Instance Groups.
  • Instance Groups. These are built from Compute Engine, etc. instances.
  • Frontends. These are the listeners on the front of the load balancer that receives traffic to be distributed to the backends.
  • Rules. These rules determine how traffic will be directed to the backends.

For your questions:

Q) Does "Protocol" mean the protocol used to receive traffic from the Load Balancer? If so, how do we set it to HTTP?

The protocol the load balancer uses to communicate with the backend. This can be HTTP, HTTPS or HTTP/2. To edit this field, click the pencil icon or drop down list depending on the screen you are on.

Q) What does "Named port" do? Where do I add a "Named port" if it is a key-value map?

A backend service sends traffic to its backends through a named port. The port name is mapped to a port number in each instance group. The Instance Group defines the key name and value for Port name.

Q) And finally, what does "Port numbers" mean? Are they the ports that the backend service will use to contact my Compute Engine instance?

A load balancer can listen on one port number and forward to a different port number on the backend. Therefore the meaning depends on which side of the load balancer. For the backend, this is the port numbers that your backend instances (Compute Engine instances) are listening on.

Related