Pickselfweighted() Weighting Not working correctly. #16778
-
|
Hi guys, I have a question regarding the pickselfweighted() function, based on this example here: pickselfweighted("http://example.com/weight", { "192.0.2.20", "203.0.113.4", "203.0.113.2" }) If I understand it correctly, with the provided IPs list, the function will automatically validate its availability, and THEN followed by the "/weight" that associates with the IPs accordingly, meaning if both "203.0.113.4", "203.0.113.2" are available as we speak AND the weighted IP like: Then the result should be --> 203.0.113.2 , right ? But I keep getting 203.0.113.4, even though the weights have already been set, and logs shows no errors. Questions: 1/ What am I missing? |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 4 replies
-
|
A weighted hash of |
Beta Was this translation helpful? Give feedback.
-
|
Maybe my previous answer was a bit short. The URL is supposed to return an answer with a number in the content. It is not the case that the highest weight always wins. From the client IP a hash is computed, and that hash is used to index (using the weights) into the list of available IPs. The hash is done to make sure that the same client IP maps to the same result IP. If you use different client IPs, the distribution of answers will be according to the weights: a high weight wil be chosen more often than a low weight. |
Beta Was this translation helpful? Give feedback.
-
|
I set up a test with two http servers on the IPs below, one returning 30 and one returning 70 for I then run (I sleep to to give caches chance to expire. 1.1.1.1 has many PoPs, queries are coming from quite some IPs to my So this all works as expected. |
Beta Was this translation helpful? Give feedback.
-
|
You are making things complicated. The code in the PowerDNS server will call the URL for all listed IPs and use the value returned to determined the weight. If a call to the URL fails for an IP, the IP is disregarded as a candidate. My test setup just returns fixed numbers by serving a static file for |
Beta Was this translation helpful? Give feedback.
You are making things complicated.
The code in the PowerDNS server will call the URL for all listed IPs and use the value returned to determined the weight. If a call to the URL fails for an IP, the IP is disregarded as a candidate.
My test setup just returns fixed numbers by serving a static file for
http://www.drijf.net/weighton both IPs. One with the content 30 and with the content 70.