Not sure why this worked when I changed the hostname from "localhost" to something custom. Nevermind I think I am unblocked now.
thanks! On Thu, May 13, 2021 at 5:09 PM 'Gaurav Poothia' via grpc.io < grpc-io@googlegroups.com> wrote: > Hello, > I am prototyping gRPC client side round robin load balancing. > So if client wants to dial to "localhost" I want it to load balance > requests round robin over different loopback addresses e.g. 127.0.0.1, > 127.0.0.2, 127.0.03 etc > > For this experiment I configured unbound (by local DSN) to appropriately > return multiple A records for "localhost" like so: > > $ dig localhost > > ; <<>> DiG 9.16.1-Ubuntu <<>> localhost > > ;; global options: +cmd > > ;; Got answer: > > ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 7826 > > ;; flags: qr aa rd ra; QUERY: 1, ANSWER: 3, AUTHORITY: 0, ADDITIONAL: 1 > > > ;; OPT PSEUDOSECTION: > > ; EDNS: version: 0, flags:; udp: 4096 > > ;; QUESTION SECTION: > > ;localhost. IN A > > > ;; ANSWER SECTION: > > localhost. 10800 IN A 127.0.0.1 > > localhost. 3600 IN A 127.0.0.3 > > localhost. 3600 IN A 127.0.0.2 > > ;; Query time: 0 msec > > ;; SERVER: 127.0.0.1#53(127.0.0.1) > > ;; WHEN: Thu May 13 23:51:33 UTC 2021 > > ;; MSG SIZE rcvd: 86 > > > I modified the hello world client in the grpc quick start guide to use > round robin LB and > > const ( > > address = "dns:///localhost:50051" > > defaultName = "world" > > ) > > func main() { > > resolver.SetDefaultScheme("dns") > > // Set up a connection to the server. > > conn, err := grpc.Dial(address, grpc.WithInsecure(), > *grpc.WithBalancerName(roundrobin.Name*)) > > if err != nil { > > log.Fatalf("did not connect: %v", err) > > } > > defer conn.Close() > > c := pb.NewGreeterClient(conn) > > When I run this I notice that the DNS resolver is returning only 1 IP > address instead 3 IPs hence there is nothing to load balance > > INFO: 2021/05/14 00:04:01 [core] parsed scheme: "dns" > > INFO: 2021/05/14 00:04:01 [core] ccResolverWrapper: sending update to cc: > {[{127.0.0.2:50051 <nil> 0 <nil>}] <nil> <nil>} > > *INFO: 2021/05/14 00:04:01 [balancer] base.baseBalancer: got new > ClientConn state: {{[{127.0.0.2:50051 <http://127.0.0.2:50051> <nil> 0 > <nil>}] <nil> <nil>} <nil>}* > > INFO: 2021/05/14 00:04:01 [core] Subchannel Connectivity change to > CONNECTING > > INFO: 2021/05/14 00:04:01 [balancer] base.baseBalancer: handle SubConn > state change: 0xc000119d10, CONNECTING > > INFO: 2021/05/14 00:04:01 [core] Subchannel picks a new address " > 127.0.0.2:50051" to connect > > INFO: 2021/05/14 00:04:01 [core] Channel Connectivity change to CONNECTING > > INFO: 2021/05/14 00:04:01 [core] Subchannel Connectivity change to READY > > INFO: 2021/05/14 00:04:01 [balancer] base.baseBalancer: handle SubConn > state change: 0xc000119d10, READY > > INFO: 2021/05/14 00:04:01 [roundrobin] roundrobinPicker: newPicker called > with info: {map[0xc000119d10:{{127.0.0.2:50051 <nil> 0 <nil>}}]} > > INFO: 2021/05/14 00:04:01 [core] Channel Connectivity change to READY > > > Any pointers on why dig(or nslookup) and the gRPC DNS resolver would > return different number of IPs for the same name? > > > Thanks in advance! > > -- > You received this message because you are subscribed to a topic in the > Google Groups "grpc.io" group. > To unsubscribe from this topic, visit > https://groups.google.com/d/topic/grpc-io/jwvUuO0Ltjs/unsubscribe. > To unsubscribe from this group and all its topics, send an email to > grpc-io+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/grpc-io/f9a7af26-522c-47dc-87e3-c05482f65c7fn%40googlegroups.com > <https://groups.google.com/d/msgid/grpc-io/f9a7af26-522c-47dc-87e3-c05482f65c7fn%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- You received this message because you are subscribed to the Google Groups "grpc.io" group. To unsubscribe from this group and stop receiving emails from it, send an email to grpc-io+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/grpc-io/CAFJ0%2B99Vgu39cubjZqZdb22e655d-cGWe9Bm4yZyYV_AABNbJg%40mail.gmail.com.