1
votes

Is it possible in GCP to create an internal load balancer that balances the traffic between two Compute Instances in different regions?

Two instances (written NAT on them) are in different regions (e.g one in us-central1 and other in asia-south1) serving something on the same ports and the internal load balancer (e.g with IP: 170.0.0.4) is accepting requests from the clients and forwarding them to these VMs.

This would help in creating a highly available service (NAT in this case) that will work even when one VM or the service or region is down.

EDIT:

Adding some more details here:

  1. Both VMs and the Load Balancer have internal IPs.
  2. Both VMs and the Load Balancer are in the same VPC network
  3. I need a layer 7 (HTTP(S)) internal lLoad balancer.
2
Which protocols are you trying to load balance? The Google Cloud internal HTTP(S) and TCP load balancers are regional and not global.John Hanley
So, that means global internal load balancers are not at all possible between two VMs for any kind of traffic?Amit Yadav
Internal load balancers are regional. Global load balancers have public IP addresses. The backends can still use private IP addresses. What protocols are you trying to load balance? Which documents are you referencing where you still have questions?John Hanley
I might be able to help you but need some more details; 1 - are your instances in the same VPC network ? 2 - Do you need a TCP (layer 4) load balancer or layer7 (http/https ) ? If you can add more to your description it would be helpful to find a workaround.Wojtek_B
@W_B please check the updated question. I have added the required detailsAmit Yadav

2 Answers

1
votes

Internal Load balancing is only regional and since you want to have back-end in different regions it will still work but you will have to set up one by yourself.

It's not possible "out of the box".

You can have a look at the Internal Load Balacing documentation which explains how this works and why. Here's also a table with available Load balancing options. If you want to configure your own LB then maybe try Envoy Proxy (or Nginx, or any solution you want).

In essence - unless you set up your own load balancer GCP doesn't have the functionality.

You could also use external load balancer (which is risky) and use it to load balance traffic and restrict external traffic to your instances (just a bunch of known IP's or ranges).

0
votes

With only two endpoints, it is impossible to use a load-balancer, because there is nothing to balance. You could only put both of them behind a load balancer, then it could balance their traffic. Moving both into the same region might be the only option to use the internal load balancer, but also here, the servers need to be put behind it.