<p>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?</p>
<p>Why the nodeport give faster? Actually the service name should be faster right?</p>

Ajin Pradeep
<p>It is expected to be faster when using the <code>NodePort</code> since the request does not rely on the <a href="https://kubernetes.io/docs/concepts/overview/components/#kube-proxy" rel="nofollow noreferrer">kube-proxy</a> to forward the traffic to the target.</p>
<p>It also depends on the way the kube-proxy is configured.</p>
<blockquote>
<p><strong>User space</strong>: This mode gets its name because the service routing takes place in kube-proxy in the user process space instead of in the kernel network stack. It is not commonly used as it is slow and outdated.</p>
<p><strong>iptables</strong>: This mode uses Linux kernel-level Netfilter rules to configure all routing for Kubernetes Services. This mode is the default for kube-proxy on most platforms. When load balancing for multiple backend pods, it uses unweighted round-robin scheduling.</p>
<p><strong>IPVS (IP Virtual Server)</strong>: Built on the Netfilter framework, IPVS implements Layer-4 load balancing in the Linux kernel, supporting multiple load-balancing algorithms, including least connections and shortest expected delay. This kube-proxy mode became generally available in Kubernetes 1.11, but it requires the Linux kernel to have the IPVS modules loaded. It is also not as widely supported by various Kubernetes networking projects as the iptables mode.</p>
</blockquote>
<p>ref: <a href="https://www.stackrox.io/blog/kubernetes-networking-demystified/#kube-proxy" rel="nofollow noreferrer">https://www.stackrox.io/blog/kubernetes-networking-demystified/#kube-proxy</a></p>
<p>On a side note, recently a new feature gate was introduced <a href="https://kubernetes.io/docs/concepts/services-networking/service-traffic-policy/" rel="nofollow noreferrer">local service-traffic-policy</a>. 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.</p>
