diff options
author | 2018-04-11 09:50:06 +0300 | |
---|---|---|
committer | 2018-04-11 07:50:06 +0100 | |
commit | a20b4fe2de5da647a3a14a105c5e71393415b0b3 (patch) | |
tree | f1ca0954f43d991ab3156273befd41a85c652ad9 /plugin/forward/proxy.go | |
parent | 5a546f743e2d694524db8d5ce02415f53d6cd045 (diff) | |
download | coredns-a20b4fe2de5da647a3a14a105c5e71393415b0b3.tar.gz coredns-a20b4fe2de5da647a3a14a105c5e71393415b0b3.tar.zst coredns-a20b4fe2de5da647a3a14a105c5e71393415b0b3.zip |
plugin/forward: use dynamic read timeout (#1659)
- each proxy stores average RTT (round trip time) of last rttCount queries.
For now, I assigned the value 4 to rttCount
- the read timeout is calculated as doubled average RTT, but it cannot
exceed default timeout
- initial avg RTT is set to a half of default timeout, so initial timeout
is equal to default timeout
- the RTT for failed read is considered equal to default timeout, so any
failed read will lead to increasing average RTT (up to default timeout)
- dynamic timeouts will let us react faster on lost UDP packets
- in future, we may develop a low-latency forward policy based on
collected RTT values of proxies
Diffstat (limited to 'plugin/forward/proxy.go')
-rw-r--r-- | plugin/forward/proxy.go | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/plugin/forward/proxy.go b/plugin/forward/proxy.go index 02d3512cb..55f285359 100644 --- a/plugin/forward/proxy.go +++ b/plugin/forward/proxy.go @@ -22,6 +22,8 @@ type Proxy struct { // health checking probe *up.Probe fails uint32 + + avgRtt int64 } // NewProxy returns a new proxy. @@ -31,6 +33,7 @@ func NewProxy(addr string, tlsConfig *tls.Config) *Proxy { fails: 0, probe: up.New(), transport: newTransport(addr, tlsConfig), + avgRtt: int64(timeout / 2), } p.client = dnsClient(tlsConfig) return p |