gRPC load balancing doesn't appear to work
See original GitHub issueFrom @ryanolson
@richarddli by just increasing the replicas in the example i get:
root@7aad1319fc7d:/devel# python greeter_client.py Greeter client received: Hello, you from host=grpc-greet-f468d5c7d-6xdvh! Greeter client received: Hello, you from host=grpc-greet-f468d5c7d-6xdvh! Greeter client received: Hello, you from host=grpc-greet-f468d5c7d-6xdvh! ... root@7aad1319fc7d:/devel# python greeter_client.py Greeter client received: Hello, you from host=grpc-greet-f468d5c7d-qzlt9! Greeter client received: Hello, you from host=grpc-greet-f468d5c7d-qzlt9! Greeter client received: Hello, you from host=grpc-greet-f468d5c7d-qzlt9! ... root@7aad1319fc7d:/devel# python greeter_client.py Greeter client received: Hello, you from host=grpc-greet-f468d5c7d-6xdvh! Greeter client received: Hello, you from host=grpc-greet-f468d5c7d-6xdvh! Greeter client received: Hello, you from host=grpc-greet-f468d5c7d-6xdvh! ...
as you can see, i get load-balancing per-invocation of a client; essentially L4 load-balancing.
however, i’m looking for 1 client, i.e. 1 grpc stub, to load-balance over all backend services - L7 note: i had to modify the greeter_server to output it’s HOSTNAME in the response; similarly, the client makes 10 repeated calls using the same stub. (I shortened the output above).
Also reported by Jean-Christophe Baey @jcbaey_twitter
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:9 (6 by maintainers)
Top Results From Across the Web
Can't get DNS load balancer to work #1482 - GitHub
It seems that code always expects GRPC running on port 80? Exposing port 80 in rootless container is not possible so this should...
Read more >The LEAST_CONN load balancing of gRPC doesn't work
We are using Istio 1.5 on AWS EKS to check the load balancing of gRPC. However, the LEAST_CONN option doesn't seem to be...
Read more >kubernetes - gRPC Load Balancing - Stack Overflow
This is the piece that's missing for making grpclb work in open source. In particular: Have a look at this document. It goes...
Read more >Load balancing gRPC in K8s without service mesh
Usually this problem is solved by using a service mesh, which will do the load balancing on layer 7 (see Linkerd, Istio).
Read more >Troubleshoot your Application Load Balancers
A security group does not allow traffic. The security group associated with an instance must allow traffic from the load balancer using the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
So we think we understand the problem and have a workaround:
Current Theory
When you create a Kubernetes
v1.Service
object you are creating a virtual host representing aniptables
rule that randomly selects Pod addresses for you (see: https://kubernetes.io/docs/concepts/services-networking/service/#virtual-ips-and-service-proxies).Envoy asynchronously queries DNS and only ever receives a single IP address from the DNS server (the Kubernetes
v1.Service
objects cluster IP). The current working assumption is that because Envoy only ever sees a single address and it is never changing that a single persistent connection is established to a backend Pod which is why traffic does not get load balanced.We need to perform more testing, but that will take some time. In the meantime we have a simple workaround detailed below:
Workaround
The workaround to this problem is use a a headless Kubernetes service. A headless Kubernetes service creates a DNS
A
record that points to the individual Pod IP addresses for a service. When Envoy performs one of its asynchronous DNS queries to populate its internal concept of a cluster then it receives <X> records from DNS where <X> represents the number running pods.You can create a headless service using the
clusterIP: None
attribute on a Kubernetesv1.Service
, for example:More information about headless services can be found in the Kubernetes docs: https://kubernetes.io/docs/concepts/services-networking/service/#headless-services
Closing this as it’s resolved with endpoint routing