nigoroll / libvmod-dynamic

The Varnish dns/named director continued
BSD 2-Clause "Simplified" License
95 stars 34 forks source link

libvmod-dynamic only uses 3 ips from 10: add tcp query support #33

Closed danielmotaleite closed 6 years ago

danielmotaleite commented 6 years ago

I have a setup where i have multiple backends (10) and use consul to manage the available backend list. Today i noticed that only a few backends (usually 3) are used, but they are always changing, on every minute, as i set TTL= 60s

$ while sleep 60; do varnishadm -n $HOSTNAME.live backend.list | grep _p  ; echo ; done 
vcl_7da98ec3-be47-4ef6-88f6-42c0208b12e0.alice_p(172.30.154.202) probe      Healthy             5/5 Thu, 25 Jan 2018 23:00:06 GMT
vcl_7da98ec3-be47-4ef6-88f6-42c0208b12e0.alice_p(172.30.243.214) probe      Healthy             5/5 Thu, 25 Jan 2018 23:01:06 GMT
vcl_7da98ec3-be47-4ef6-88f6-42c0208b12e0.alice_p(172.30.249.132) probe      Healthy             5/5 Thu, 25 Jan 2018 23:01:06 GMT

vcl_7da98ec3-be47-4ef6-88f6-42c0208b12e0.alice_p(172.30.243.214) probe      Healthy             5/5 Thu, 25 Jan 2018 23:01:06 GMT
vcl_7da98ec3-be47-4ef6-88f6-42c0208b12e0.alice_p(172.30.219.96) probe      Healthy             5/5 Thu, 25 Jan 2018 23:02:06 GMT
vcl_7da98ec3-be47-4ef6-88f6-42c0208b12e0.alice_p(172.30.150.186) probe      Healthy             5/5 Thu, 25 Jan 2018 23:02:06 GMT

vcl_7da98ec3-be47-4ef6-88f6-42c0208b12e0.alice_p(172.30.249.132) probe      Healthy             5/5 Thu, 25 Jan 2018 23:03:06 GMT
vcl_7da98ec3-be47-4ef6-88f6-42c0208b12e0.alice_p(172.30.251.37) probe      Healthy             5/5 Thu, 25 Jan 2018 23:03:06 GMT
vcl_7da98ec3-be47-4ef6-88f6-42c0208b12e0.alice_p(172.30.154.202) probe      Healthy             5/5 Thu, 25 Jan 2018 23:03:06 GMT

vcl_7da98ec3-be47-4ef6-88f6-42c0208b12e0.alice_p(172.30.251.37) probe      Healthy             5/5 Thu, 25 Jan 2018 23:03:06 GMT
vcl_7da98ec3-be47-4ef6-88f6-42c0208b12e0.alice_p(172.30.161.48) probe      Healthy             5/5 Thu, 25 Jan 2018 23:04:06 GMT
vcl_7da98ec3-be47-4ef6-88f6-42c0208b12e0.alice_p(172.30.209.195) probe      Healthy             5/5 Thu, 25 Jan 2018 23:04:06 GMT

A normal udp query return 3 entries:

$ host  alice-live-p.service.consul.
alice-live-p.service.consul has address 172.30.209.195
alice-live-p.service.consul has address 172.30.251.37
alice-live-p.service.consul has address 172.30.161.48

but using TCP query, we get the list of 10 IPs:

$ host -T  alice-live-p.service.consul.
alice-live-p.service.consul has address 172.30.251.37
alice-live-p.service.consul has address 172.30.219.96
alice-live-p.service.consul has address 172.30.150.186
alice-live-p.service.consul has address 172.30.209.195
alice-live-p.service.consul has address 172.30.133.54
alice-live-p.service.consul has address 172.30.154.202
alice-live-p.service.consul has address 172.30.161.48
alice-live-p.service.consul has address 172.30.137.218
alice-live-p.service.consul has address 172.30.249.132
alice-live-p.service.consul has address 172.30.243.214

So looks like the module is using UDP for the query... i think if there is support for TCP queries, it maybe would return the 10 IP list and use all the available backends

danielmotaleite commented 6 years ago

Sorry about the noise, this is actually a problem with consul dns resolver, it needs this option:

  "dns_config": [ {"enable_truncate": true} ],

So it returns more than 3 IPs. After adding the new config and restart consul, varnish now detects all the IPs for that dns

nigoroll commented 5 years ago

as of 256b1f01677793f4363318830d7e61ff4de2c0fc, with getdns support, you can now specify TCP transport with

<resolver_object>.add_transport(TCP);
<resolver_object>.set_transports();