Search code examples
google-cloud-platformgoogle-compute-enginehigh-availabilitygoogle-cloud-internal-load-balancergcp-load-balancer

GCP internal load balancer between two VMs (Compute instances)


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.

Solution

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