Unable to get gRPC DNS resolver to return multiple IP addresses

17 views
Skip to first unread message

Gaurav Poothia

unread,
May 13, 2021, 8:09:49 PMMay 13
to grpc.io
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  <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!

Gaurav Poothia

unread,
May 14, 2021, 12:58:52 AMMay 14
to Gaurav Poothia, grpc.io
Not sure why this worked when I changed the hostname from "localhost" to something custom.
Nevermind I think I am unblocked now.

thanks!

--
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+u...@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.
Reply all
Reply to author
Forward
0 new messages