[ what timing does unbound perform DNS prefetch ? ]
Seen from source files , prefetching algorithm is :
If TTL in the cache reaches 90% of original TTL , unbound seems to perform prefetch
For example :
Seen from source files , prefetching algorithm is :
If TTL in the cache reaches 90% of original TTL , unbound seems to perform prefetch
# find . -name "*" | xargs grep -i prefetch ./util/data/msgreply.c: rep->prefetch_ttl = prettl; ./util/data/msgreply.c: rep->prefetch_ttl = PREFETCH_TTL_CALC(rep->ttl); ./util/data/msgreply.c: rep->prefetch_ttl += timenow; ./util/data/msgreply.c: rep->ttl, rep->prefetch_ttl, rep->an_numrrsets, ./util/data/msgreply.h:/** calculate the prefetch TTL as 90% of original. Calculation ./util/data/msgreply.h:#define PREFETCH_TTL_CALC(ttl) ((ttl) - (ttl)/10) |
For example :
original TTL : 30 seconds
90% of original TTL : 30 - 30/10 = 27
In this example , unbound will perform prefetch when the remaining of TTL reaches less 3 seconds.
30(100%) - 27(90%) = 3
Please note that unbound will not perform prefetch if there are no requests of this query , even though TTL is less 3 seconds.
[ when prefetch enabled ]
unbound.conf ( default is no )
name resolution for www.facebook.com.
original TTL is 30 seconds.
repeat dig command.
Seen from TTL and Query time , you could find whether unbound performes prefetch or not.
debug logs
[ when prefetch disabled ]
unbound.conf ( default is no )
unbound does not perform prefetch.
When enabling prefetch , common sites ( FQDNs ) will be cached before expiring its data.
Benefits of this technique are low latency and high caching hit rate.
90% of original TTL : 30 - 30/10 = 27
In this example , unbound will perform prefetch when the remaining of TTL reaches less 3 seconds.
30(100%) - 27(90%) = 3
Please note that unbound will not perform prefetch if there are no requests of this query , even though TTL is less 3 seconds.
[ when prefetch enabled ]
unbound.conf ( default is no )
prefetch: yes |
name resolution for www.facebook.com.
original TTL is 30 seconds.
root@hat1:~/unbound-1.4.13# dig @127.1 www.facebook.com. ; <<>> DiG 9.9.0a2 <<>> @127.1 www.facebook.com. ; (1 server found) ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 40433 ;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0 ;; QUESTION SECTION: ;www.facebook.com. IN A ;; ANSWER SECTION: www.facebook.com. 30 IN A 69.171.228.12 |
repeat dig command.
Seen from TTL and Query time , you could find whether unbound performes prefetch or not.
root@hat1:~/unbound-1.4.13# dig @127.1 www.facebook.com. ; <<>> DiG 9.9.0a2 <<>> @127.1 www.facebook.com. ; (1 server found) ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 55959 ;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0 ;; QUESTION SECTION: ;www.facebook.com. IN A ;; ANSWER SECTION: www.facebook.com. 3 IN A 69.171.228.12 ;; Query time: 0 msec ;; SERVER: 127.0.0.1#53(127.0.0.1) ;; MSG SIZE rcvd: 50 root@hat1:~/unbound-1.4.13# dig @127.1 www.facebook.com. ; <<>> DiG 9.9.0a2 <<>> @127.1 www.facebook.com. ; (1 server found) ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 37955 ;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0 ;; QUESTION SECTION: ;www.facebook.com. IN A ;; ANSWER SECTION: www.facebook.com. 30 IN A 69.171.229.14 ;; Query time: 0 msec ;; SERVER: 127.0.0.1#53(127.0.0.1) ;; MSG SIZE rcvd: 50 |
debug logs
unbound: [1385:0] info: server stats for thread 0: 19 queries, 18 answers from cache, 1 recursions, 1 prefetch |
[ when prefetch disabled ]
unbound.conf ( default is no )
prefetch: no |
unbound does not perform prefetch.
root@hat1:~/unbound-1.4.13# dig @127.1 www.facebook.com. ; <<>> DiG 9.9.0a2 <<>> @127.1 www.facebook.com. ; (1 server found) ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 65369 ;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0 ;; QUESTION SECTION: ;www.facebook.com. IN A ;; ANSWER SECTION: www.facebook.com. 0 IN A 69.171.228.12 ;; Query time: 0 msec ;; SERVER: 127.0.0.1#53(127.0.0.1) ;; WHEN: Thu Oct 13 01:33:40 2011 ;; MSG SIZE rcvd: 50 root@hat1:~/unbound-1.4.13# dig @127.1 www.facebook.com. ; <<>> DiG 9.9.0a2 <<>> @127.1 www.facebook.com. ; (1 server found) ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 25443 ;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0 ;; QUESTION SECTION: ;www.facebook.com. IN A ;; ANSWER SECTION: www.facebook.com. 0 IN A 69.171.228.12 ;; Query time: 0 msec ;; SERVER: 127.0.0.1#53(127.0.0.1) ;; MSG SIZE rcvd: 50 root@hat1:~/unbound-1.4.13# dig @127.1 www.facebook.com. ; <<>> DiG 9.9.0a2 <<>> @127.1 www.facebook.com. ; (1 server found) ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 49418 ;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0 ;; QUESTION SECTION: ;www.facebook.com. IN A ;; ANSWER SECTION: www.facebook.com. 30 IN A 66.220.149.18 ;; Query time: 116 msec ;; SERVER: 127.0.0.1#53(127.0.0.1) ;; MSG SIZE rcvd: 50 |
When enabling prefetch , common sites ( FQDNs ) will be cached before expiring its data.
Benefits of this technique are low latency and high caching hit rate.
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.