Does GRPC broadcast the request to ALL servers on the DNS when using round_robin?

Viewed 18

I had a weird bug on my code and I am not sure if it is because of my understanding of how Round Robin works in GRPC.

I have a manager channel builder like this where I pass in a hostname which is a DNS-RR Docker service.

        final ManagedChannelBuilder<?> builder =
            ManagedChannelBuilder.forAddress(hostname, 6565)
                .defaultLoadBalancingPolicy("round_robin")
                .usePlaintext()
                .intercept(
                    new ClientInterceptor() {
                        @Override
                        public <R, Q> ClientCall<R, Q> interceptCall(
                            MethodDescriptor<R, Q> method, CallOptions callOptions, Channel next) {

                            log.info("{}", method.getFullMethodName());
                            return next.newCall(method, callOptions);
                        }
                    },
                    grpcTracing.newClientInterceptor())
                .enableRetry()
                .maxRetryAttempts(5);

I don't have the logs when it occured yet but it seemed that it seemed to keep on calling every node.

I don't want to choose pick_first because that means everything will go to one node, I was expecting round_robin to choose between available ones for each request.

1 Answers

The round_robin loadbalancing policy would choose only one backend for each attempt.

If you have retries enabled though, it is possible that the first attempt failed and the subsequent retries went to the different backends.

Related