I am struggling to get the load balancer to work with more than one application. My setup:
Applications: Web1 (Port 10000), Web2 (Port 11000), Web3 (Port 12000)
Servers: Serv1, Serv2, Serv3.
All servers are identical and have Web1, Web2 and Web3 listening on port: 10000, 11000, 12000 respectively.
How can I instruct the load balancer to do the following:
web1.domain.com -----> use Serv1,Serv2,Serv3 port 10000.
web2.domain.com -----> use Serv1,Serv2,Serv3 port 11000.
web3.domain.com -----> use Serv1,Serv2,Serv3 port 12000.
I managed to get it working with 1 application but I can't create 3 load balancers as the servers already belongs to a different instance group.
I have read about the port name mapping, but the load balancer keeps ignoring those and uses its own generated one called 'http'.
Has anyone faced any similar issues?
If you setup those three different backend ports as named ports in the instance group containing those three servers, this setup should work. I've given it a try, setting up an Apache webserver listening on three different ports, and it worked.
Here's the steps I took to have a setup like the one you're describing working correctly:
gcloud
, try running this command: gcloud compute instance-groups set-named-ports "NAME_OF_INSTANCE_GROUP" --zone "INSTANCE_GROUP_ZONE" --named-ports "port0:10000,port1:11000,port2:12000"
;gcloud
, make sure you set the --port-name
argument to one of the named ports of the instance group;Following these steps, I got a load-balancer that was capable of reaching the same instance group in three different ports simply using three different DNS hostnames.
Be aware that there are important restrictions to this kind of setup, with the more relevant restrictions being:
- Both backends must use the same balancing mode, either UTILIZATION or RATE.
- You can use maxRatePerInstance and maxRatePerGroup together. It is acceptable to set one backend to use maxRatePerInstance and the other to maxRatePerGroup.
- If your instance group serves two or more ports for several backends respectively, you have to specify different port names in the instance group.
Finally, you can test this setup out using curl:
curl --resolve "web3.domain.com:FRONTEND_PORT:PUBLIC_IP_OF_LB" http://web3.domain.com/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With