I managed to set up autoscaling based on an external load balancer, but I didn't find a way to do the same for an internal load balancer.
Is this feature supported, how to go about auto-scaling my instance group based on the internal load balancer?
The issue is, when you configure an instance group to scale by HTTP requests, you need an HTTP load balancer, which is internet facing, So, the UDP load balancer, which can be internal doesn't work for that.
The Internal Load Balancer uses a backend service which can use a managed instance group. You can assign a managed instance group to the backend or target pools of both internal and network load balancers.
Keep in mind that the Network Load Balancer uses target pools instead of backend services, but target pools can use managed instance groups as well.
Take a look at the documentation for more details. Alternatively I found this and this posts that I believe can be useful to you.
From your last comment:
I'm not able to setup a TCP load balancer which has a backend service, I only get a REGIONAL backend service, which doesn't support http load balancing..
As stated in the Internal Load Balancing Concepts, "internal client requests stay internal to your VPC network and region", so there is neither need of HTTP here, nor a multi-regional setup.
On the same page, under section "About Internal Load Balancing", the schema shows a classic load balancing architecture, featuring one global (http) and multiple internal (tcp/udp) load balancers for each region.
Further on, under "Deploying Internal Load Balancing with clients across VPN or Interconnect", the following is stated in an "Important" note:
Internal Load Balancing is a regional product. [...] An internal load balancer cannot forward or receive traffic to and from VM instances in other regions.
Basically, if your managed instance group has instances across multiple regions, then you need an external load balancer, but if all your instances are within the same region (instances can be split across zones within this same region, e.g. us-west1-a/b/c), then you can rely on an internal load balancer.
Related
I am creating a global HTTPS Load Balancer in Google Cloud and wondering how does location affect a global load balancer.
I am unable to find much detail about it on internet.
There are price differences based on location:
https://cloud.google.com/vpc/network-pricing#lb
but no idea how it affects routing of https requests:
https://storage.googleapis.com/gweb-cloudblog-publish/images/global_lb.max-1800x1800.png
For example: if my website receives most of its traffic from USA, India and Europe then what would be the best location I should choose while setting up global HTTPS Load Balancer and what difference it will make?
The primary difference is that the global load balancing is for Layer-7 (high-level application layer) traffic while regional load balance is for Layer-4 (transport layer) traffic and uses Maglev for traffic routing.
Let's say you want to do your own SSL terminations and operate your own Layer-7 reverse proxies, I believe regional is the correct option. For the vast majority of users I would wager that global is the better choice.
Have a look at the documentation Cloud Load Balancing overview section Global versus regional load balancing:
Use global load balancing when your backends are distributed
across multiple regions, your users need access to the same
applications and content, and you want to provide access by using a
single anycast IP address. Global load balancing can also provide IPv6
termination.
Use regional load balancing when your backends are in one region,
and you only require IPv4 termination.
and at section External HTTP(S) Load Balancing:
HTTP(S) Load Balancing is implemented on GFEs. GFEs are
distributed globally and operate together using Google's global
network and control plane. In Premium Tier, GFEs offer cross-regional
load balancing, directing traffic to the closest healthy backend that
has capacity and terminating HTTP(S) traffic as close as possible to
your users.
more information about Network Service Tiers you can find in this article.
To find more details have a look at the documentation External HTTP(S) Load Balancing overview:
HTTP(S) Load Balancing is a global service when the Premium Network
Service Tier is used.
and
When a user request comes in, the load balancing service determines the approximate origin of the request from the source IP address.
The load balancing service knows the locations of the instances owned by the backend service, their overall capacity, and their
overall current usage.
If the closest instances to the user have available capacity, the request is forwarded to that closest set of instances.
Incoming requests to the given region are distributed evenly across all available backend services and instances in that region. However,
at very small loads, the distribution may appear to be uneven.
If there are no healthy instances with available capacity in a given region, the load balancer instead sends the request to the next
closest region with available capacity.
also
HTTP(S) Load Balancing is a regional service when the Standard Network
Service Tier is used. Its backend instance groups or NEGs must all be
located in the region used by the load balancer's external IP address
and forwarding rule.
Meanwhile, Maglev is a distributed system for Network Load Balancing.
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:
Both VMs and the Load Balancer have internal IPs.
Both VMs and the Load Balancer are in the same VPC network
I need a layer 7 (HTTP(S)) internal lLoad balancer.
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).
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.
We currently use a single AWS classic load balancer per EC2. This was cost effective for not many EC2s but now we're a growing project, we have 8 Classic Load Balancers which is starting to cost more than we'd like
What could I do to consolidate these multiple load balancers into a single load balancer?
The current load balancers are only used to forward HTTP/HTTPs traffic to an EC2 that's registered against it
I have DNS A records setup to route to the load balancers
Without knowing all the details, you might be better creating a single application load balancer with multiple target groups, this way it's only one load balancer and then you have the segregation at target group level rather than load balancer level.
If you need http/s access to some pieces of infrastructure and app access to others then you might consider one network LB and one application LB.
We are in process of setting up an infrastructure where we have several services hosted and we have separate Internal Load Balancer for each service.
If we have global Load balancer in front of internal load balancer. Can someone please help and tell me how the various services can communicate with each other. Would it be via global HTTP LB ? Is this the right approach. Would really appreciate your help.
I expect your "global load balancer" is set up with a global external IP and so reachable by external clients via the internet.
If you use an internal load balancer to further distribute the load to instances within your VPC inside the GCP project, there is no need to call the external IP to communicate with other services inside your GCP project.
You can directly execute calls against the IP address of the internal load balancer.
Note you can either let GCP allocate any free IP address within your VPC, or you can select the IP address within the address range of the selected VPC.
See also the following documentation about internal load balancers:
https://cloud.google.com/compute/docs/load-balancing/internal/
You can't reuse the same Instance Group as backend for HTTP(S) Load Balancing and for an Internal Load Balancer.
What you can do is use HTTP(s) Load Balancing for both internal and external clients.
Otherwise, you can run a HTTP proxy service in the HTTP(s) Load Balancing backends, and forward the requests to the internal load balanced IP.
I am working on AWS. I have a doubt regarding how many applications a load balancer can support.
Like if I have an application whose traffic is routed and managed by one load balancer, then can I use that LB for another application also???
Also if I can use that ELB for another applications also than how ELB will get to know that which traffic should be routed to Application A server and which to Application B server??
Thanks
I think you may be misunderstanding the role of the load balancer. The whole point of a load balancer is that any of the servers behind it can provide any of the services. By setting it up this way you ensure that the failure of any one server will not affect availability of the service.
You can load balance any TCP service such as HTTP just by adding it as a "listener" for the ELB. The ELB can therefore support as many applications as you want to forward to the servers behind it.
If you set up an image of a server that provides all the services you need, you can even have the ELB auto scale the number of servers up and down by launching or terminating instances from that image as the load varies.