-
Notifications
You must be signed in to change notification settings - Fork 672
[dns] caching for local domain #225
Comments
One possibility here is to invert the information flow, moving from 'pull' to 'push', e.g. by gossiping records between peers. The trouble with doing that naively is that we'd end up with every record everywhere, which doesn't scale. |
Nodes could share their DNS records by piggybacking their local DNS knowledge in gossip messages, or by explicitly pushing information to some random peers (memberlist uses this mechanism). This would increase the hit rate when looking for DNS names in the local records and, in case of a miss, the nodes could fall back to doing the regular resolution system... |
As I said above, the trouble with naive 'push' is that that we end up with every record everywhere. |
But this is not necessarily a bad thing, right? Unless you have a huge number of records, having all the records in all the nodes is not bad IMO. Nodes should just have a hard limit in the memory used for this table though... |
It's not just about memory use but also the amount of information you need to shunt around the network. Storing every record everywhere is bad. Transmitting every record everywhere is bad too. |
Indeed, the push protocol would have to be carefully designed, but this kind of gossip protocol, in the same spirit as SWIM, wouldn't add too much overhead for small networks. I think you could extrapolate the results from this simulator for calculating how much traffic it would add... |
The protocol overhead isn't the problem. The size of the data and frequency of update is, both of which can be expected to increase linearly with scale out, which will overwhelm network and processing capacity at some point. In most networks there will be a natural segmentation of the namespace - you won't have all nodes querying DNS for all names. There is therefore no good reasons for nodes to be told about, or hold onto, DNS entries that their local containers have never asked for. Other than attempting to reduce latency for the first query for a name, but I'd rather give up that than design something inherently unscalable. That's not to say that a naive push couldn't be good enough for starters, just as the (somewhat less naive, but still imperfect) pull is. Btw, another difference between 'push' and 'pull' is that the former requires a custom protocol whereas 'pull' can be based on standard DNS. Using standard protocols is incredibly handy for debugging and tooling in general. It's not a major design pivot though; features and performance are more important. |
Then I would start with the piggybacking propagation. When a node X sends a UDP packet to a node Y, it could add some random entries from the local DNS cache if any remaining space is available in the packet (up to the maximum capacity, the path MTU). This method would not replace the current "pull" mechanism, but it would increase the hit ratio, a first step towards a more elaborated solution... |
…self-contained improved API, more friendly for the `DNSServer` class
…self-contained improved API, more friendly for the `DNSServer` class
…he least useful entries...
… truncated responses)
…ht TTL to answers, as well as the authoritative flag
increase logs verbosity in the unit tests
use a private mDNS client per local worker
… cache after garbage collecting entries
fix in getReply(): only return something when we really have a reply...
So if a mapping in X exists for that name, |
The whole point of doing something more complicated is to be able to use a longer TTL. The shorter the ttl the more DNS traffic there is on the network.
Peers can just broadcast "I am interested in name A" when resolving A and the cache misses. In fact this is what happens now; the mdns broadcast contains just that information. But we need more than that:
All of this is very similar to what we are doing in #390 for communicating IP reservations between peers. |
Obviously we want to increase the TTL, but I think we both agree that mDNS is a clearly limited solution and we must use short TTLs until we have a better solution...
That would be a nice change but it would involve a lot of work, and I'm a bit concerned about this extra communication step between WeaveDNS and the router, but it can be done... |
@squaremo "caching" to "cache local RRs"? why only the local RRs? don't we want to cache replies obtained recursively? |
Because that's what the issue actually describes and the subsequent comments discuss. |
Maybe we could create another issue for moving WeaveDNS to gossip communications, then we could start discussing how to do it... (and @rade would probably be the right person for filling the issue). |
We could, but that is quite a long way down the road. And gossiping is an implementation detail - issues should describe features/problems. |
@alvaro I think this is resolved by #429 provided there is some clarification on the following part of this issue's description: "In its most basic form a dns peer would: remember all answers returned from a broadcast query, including their ttls". We are not doing that, are we? i.e. if we get responses from multiple servers, the cache entries get overwritten, so we only keep the response from one server. I am ok with that, but please point out (and if necessary create) the issues were that is addressed. #226 is a possible candidate, but looks quite broad. |
@rade Current implementation does not cache all responses it gets from the network, but only the first one. When WeaveDNS is asked about a local name it will
Following answers to the mDNS query will be simply ignored. The answer will be always cached for 30 seconds (we are currently using a hardcoded TTL for local answers). So we are caching the response from the fastest peer... Multiple responses from peers will be processed and remembered when #338 is addressed (I'm working on that) (and, as a side effect, we will have an initial solution for #226). |
ok. #338 is about a single peer returning multiple responses, i.e. when there are multiple containers with the same name on that peer. |
Closed by #429. |
At present, weavedns first attempts to resolve names against the records from local containers. If that fails then it asks other peers and returns the first answer. This has some significant shortcomings...
The obvious solution is to introduce caching.
In its most basic form a dns peer would:
The shortcomings of this basic approach are principally around the danger of returning stale entries vs achieving good performance and scalability. Still, I reckon it's good enough for starters, and even with a short ttl an improvement over the present situation.
The text was updated successfully, but these errors were encountered: