I have 2 k8s application running in a single cluster. When it communicate with service name, it takes 12 seconds to transfer 1 GB data. When communicate with nodeport time is 8sec. Why the service name is slow?
Why the nodeport give faster? Actually the service name should be faster right?
It is expected to be faster when using the
NodePort
since the request does not rely on the kube-proxy to forward the traffic to the target.It also depends on the way the kube-proxy is configured.
ref: https://www.stackrox.io/blog/kubernetes-networking-demystified/#kube-proxy
On a side note, recently a new feature gate was introduced local service-traffic-policy. While it's still going through the kube-proxy, it will also reduce roundtrips since it routes traffic only to the same node. Maybe you want to test this as an experiment.