Speed difference through Google cloud load balancer

3/19/2020

We have k8s cluster with apps hosted on GKE. When we are trying to get static content (8.25Mb) through Google cloud load balancer retrieving time is 3.8s, when we are trying do it directly through nginx on our k8s cluster in VM it takes 0.2s. What can be a reason of speed difference? Does Google cloud load balancer have any settings for example for bandwidth?

~$ wget https://.../main.js
...
HTTP request sent, awaiting response... 200 OK
Length: 8649943 (8.2M) [application/javascript]
Saving to: 'main.js'
main.js               100%[========================================================================================>]   8.25M  2.27MB/s    in 3.8s 


__________________________________

Nginx

~$ wget https://.../main.js
...
Saving to: 'main.js'
main.js               100%[========================================================================================>]   8.25M  50.2MB/s    in 0.2s
-- Yulia Sh
google-cloud-load-balancer
google-cloud-platform
google-kubernetes-engine

1 Answer

3/19/2020

I wouldn't say it is related with loadbalancer. Keep in mind that downloading something that is hosted in the cloud will always take considerably more time then something available locally.

If you have such suspition that loadbalancer could make a difference, you should rather compare it with the speed when downloading directly from your GKE node. You can expose your nginx Deployment via NodePort Service and avoid this way using loadbalancer. If such download will take much less time than downloading through loadbalancer then you could blame the loadbalancer. But I'm quite sure that the result will be almost the same.

Where do you have your local k8s cluster ? Is it somewhere on your local network ? Or maybe on a VM running on the same machine from which you're executing wget ? If so, it will always take much less time than downloading from any cloud-hosted VM.

The network parameters such as download speed and latency will also depend on what region is your GKE cluster hosted in. If this is some region which is located quite far away from your location, those parameters can differ quite considerably comparing with the one that is located relatively near to you.

-- mario
Source: StackOverflow