2
votes

I am new to Google compute engine and I am try to setup network load balancing having 2 VMs for serving web pages.

For ex, I have 2 VMs - app1 and app2 - both having apache server and serves simple web page.

Both VMs are running with Red Hat Enterprise Linux Server release 7.0 (Maipo)

I am able to access both web pages through the IP in browser.

I created network load balancing setup and both apps are showing in green in target pool which means load balancer is able to connect to both VMs.

But, when I hit the IP of load balancer, it is rendering page from only one server. If I manually stop the server in the VM, load balancer IP redirects to other app. I believe load balancer is able to identify health of both VMs and able to redirect.

But it is not balancing the traffic. Can anyone help me to solve this issue?

2
Have you confirmed session affinity while creating the target pool? - Faizan
I didn't want to start with session affinity for the initial setup, so didn't enable that. As per documentation, if I have enabled session affinity with client IP, then this is correct. but without session affinity, it should be going to both VMs in round robin. - Saravanan S
I think network load balancer doesn't forward the traffic on round robin bases. I was able to test it with the load balancer setup that I have. As per the document "By default, to distribute traffic to instances, Google Compute Engine picks an instance based on a hash of the source IP and port and the destination IP and port." [1] cloud.google.com/compute/docs/load-balancing/network - Faizan
Oh. that might be a reason. But as per the video they have provided, it was supposed to do round robin balancing. I applied session affinity now and it seems to be working as expected. - Saravanan S
I will post my comment as an answer so that you can accept it which might help someone else with the similar issue. - Faizan

2 Answers

3
votes

I think that the network load balancer doesn't forward the traffic on a round-robin basis. I was able to test it with the load balancer setup that I have. As per the documentation:

By default, to distribute traffic to instances, Google Compute Engine picks an instance based on a hash of the source IP and port and the destination IP and port.

0
votes

HTTP/S load balancing will proxy requests in a round-robin fashion. https://cloud.google.com/compute/docs/load-balancing/http/