Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

swarm: dial DNS addresses in parallel with IP addresses #2292

Open
sukunrt opened this issue May 15, 2023 · 2 comments
Open

swarm: dial DNS addresses in parallel with IP addresses #2292

sukunrt opened this issue May 15, 2023 · 2 comments
Assignees
Labels
P1 High: Likely tackled by core team if no one steps up

Comments

@sukunrt
Copy link
Member

sukunrt commented May 15, 2023

We dial a peer after resolving any dns addresses of the peer. We should dial the IP addresses and resolve the dns addresses in parallel.

@marten-seemann
Copy link
Contributor

That's a good point. I imagine that DNS addresses will become more prevalent once we enable libp2p+HTTP services, so resolving this will become even more important in the future.

Two questions:

  1. How exactly will the prioritization logic look like? For example, we might know the TCP addresses, and receive some QUIC addresses from DNS? We probably don't want to cancel the TCP dial attempt. Would we now start a QUIC dial right away? Might make sense to do so in the case of QUIC. However, what if we only knew an IPv4 address and now receive an IPv6 address? Probably not worth it in that case.
  2. I'm curious how this interacts with DNS caching. We will run into this when we dial the same peer multiple times (or, less likely, if multiple peers share a domain name). When using our DoH resolver, it might make sense to introduce a "only if cached mode" for our lookups. That would allow us to do the dial prioritization with the complete set of addresses, instead of starting dials with a smaller subset, and then adding the resolved addresses half a millisecond later.

@p-shahi p-shahi added the P1 High: Likely tackled by core team if no one steps up label May 22, 2023
@sukunrt
Copy link
Member Author

sukunrt commented Jun 11, 2023

I think this is a good start.

  1. From the list of peer addresses, resolve all dns addresses only from cache.
  2. Rank the IP addresses that we have
  3. Begin dialling the IP addresses according to the ranking logic. In parallel, begin resolving the DNS addresses
  4. Add addresses from DNS resolution to the dial queue.
    a. If TCP dials are in flight we ignore the inflight dials and proceed to dialing the received addresses right away based on the dial prioritisation logic. So if we received two new QUIC addresses and a new TCP we will dial one of them immediately and wait 250ms and then dial the next one and then 250ms later dial the TCP address.
    b. If a QUIC dial is in flight we delay the new address dials by 250ms wrt the start of the QUIC dial in flight. Here we ensure happy eyeballs, if a QUIC IPv6 dial is in flight we rank received QUIC IPv4 higher than QUIC IPv6. If a QUIC IPv4 dial is in flight we rank the received IPv6 address higher than the IPv4 address.
  5. Keep dialling addresses from the dial queue.

NOTE: This ignores the recommendation from the Happy Eyeballs RFC to wait 30ms for receiving a AAAA record after receiving an A record when resolving the dns address. We can take that up after we have this in place.

I'm not completely sold on resolving DNS in parallel with IP addresses. We can wait also wait for 250ms if some QUIC dials are in progress before beginning DNS resolution. But doing DNS resolution in parallel makes the algorithm much simpler.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P1 High: Likely tackled by core team if no one steps up
Projects
None yet
Development

No branches or pull requests

3 participants