-
Notifications
You must be signed in to change notification settings - Fork 137
resolver: Compress all DNS answers #173
Conversation
This patch makes mesos-dns compress all DNS answers. This improves performance of many DNS questions which, when compressed, fit in 512 bytes. See https://tools.ietf.org/html/rfc1035#section-4.2.1 Fixes #170 because the native Go DNS resolver which is enabled when statically compiling doesn't fallback to TCP when failing to decode a UDP response larger than 512 bytes. It isn't a perfect solution since an answer might be larger than 512 bytes even after compression but that's an issue with the client resolver.
Fixes #170. |
My first inclination was to request that you file a miekg/dns issue (or perhaps a PR) to properly set the "truncated" flag on UDP responses (and only on UDP responses) that are greater than 512 bytes in length. From the spec:
In the miekg/dns code the length is not checked and the message is returned as-is: However it looks like he's rejected the idea of fixing this problem in the lib. So we might want to do the ugly thing suggested here for clients that don't advertise large enough payload size - they'd probably want the TC bit set if information was missing: And we probably want to allow payloads > 512 without setting the TC bit in some circumstances: So I think our approach to resolving the problem more broadly needs a little more work. Thoughts? |
@jdef: The pure Go stdlib DNS implementation doesn't implement RFC6891. It also doesn't fallback correctly to TCP even if the TC bit is set in a UDP reply. What we can do on our side to fix #170 is to compress the responses in a best effort policy. For protocol compliance I'll add the code to also set the TC bit. Now, if we want to support RFC6891 on our side, I think we should open a separate issue for that and wait for miekg/dns#223 to be implemented. |
Sounds like a plan. Let's stop the bleeding with best effort compress and On Thu, Jun 18, 2015 at 10:42 AM, Tomás Senart [email protected]
|
PTAL |
@@ -349,8 +349,8 @@ func (res *Resolver) HandleNonMesos(w dns.ResponseWriter, r *dns.Msg) { | |||
} | |||
} | |||
|
|||
err = w.WriteMsg(m) | |||
if err != nil { | |||
m.Compress = true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would like to see some TODO comments here describing the pain point and the potential problems that a user will see until we resolve this properly. Perhaps even a reference to tickets 173 and 174.
minor doc nit, otherwise lgtm |
resolver: Compress all DNS answers
Just an update to this since I'm running into this as well:
But you have to send back a response of < 512 in order to get to that check. There still hasn't been any traction yet on miekg/dns#223 but you can try and just use the |
This patch makes mesos-dns compress all DNS answers. This improves
performance of many DNS questions which, when compressed, fit in 512
bytes. See https://tools.ietf.org/html/rfc1035#section-4.2.1
Fixes #170 because the native Go DNS resolver which is enabled when
statically compiling doesn't fallback to TCP when failing to decode
a UDP response larger than 512 bytes.
It isn't a perfect solution since an answer might be larger than 512
bytes even after compression but that's an issue with the client
resolver.