1

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.
Amit Yadav
  • 4,422
  • 5
  • 34
  • 79
  • 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 Mar 26 '20 at 15:50
  • So, that means global internal load balancers are not at all possible between two VMs for any kind of traffic? – Amit Yadav Mar 26 '20 at 17:36
  • 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 Mar 26 '20 at 17:42
  • 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 Mar 27 '20 at 08:27
  • @W_B please check the updated question. I have added the required details – Amit Yadav Mar 27 '20 at 09:26
  • @JohnHanley as of now I don't have a document to refer to or doesn't have a lead to move forward. I am looking for an global internal load balancer between two VMs balancing HTTP(S) protocol. – Amit Yadav Mar 27 '20 at 09:31
  • Is the load balancer has to be accessible from the Internet or just from inside your VPC ? – Wojtek_B Mar 27 '20 at 14:25
  • It is an internal IP load balancer, it is by default accessible only from within the VPC :) – Amit Yadav Mar 27 '20 at 14:39

2 Answers2

1

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).

Wojtek_B
  • 4,245
  • 1
  • 7
  • 21
0

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.

Martin Zeitler
  • 1
  • 19
  • 155
  • 216