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

inet_res: rewrite to parallel lookup algorithm #4610

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

RaimoNiskanen
Copy link
Contributor

This is a suggestion that needs to be evaluated. The concept popped up in the discussion of #4564 and I happened to have this branch already.

I have rewritten the inet_res DNS resolver to query name servers in parallel, which seems to be the contemporary way to do it.

To avoid wasting resources there is a delay of half the normal UDP time-out before a new name server is queried, so the queries are not entirely parallel. The question is if this is too defensive?

To ensure process cleanup there is a Reaper process started for every query, and all queries are performed in parallel processes. That means at least 2 processes are spawned for a query, and then after half the normal UDP time-out another is spawned up to 1 process per name server + the Reaper. The question is if this expending too much resources - I did not find a better way to do it.

Because queries are done in parallel this algorithm uses more sockets i.e more IP Ports and more file descriptors. The current algorithm uses one UDP socket, and possibly one TCP socket if needed. This algorithm uses one socket per query process which go up to one per name server. The question is if this might be a problem for systems where IP Ports or file descriptors are a scarce resource.

So, is this a good improvement, or wasting resources?

@RoadRunnr
Copy link
Contributor

What that this does is sending the same query to multiple NS in parallel. While that is a welcome addition, what I'm missing more is the ability to send A and AAAA queries in parallel to the same NS. For the native resolvers it is standard to do that when the desire address family is set to PF_UNSPEC. In Erlang every user of inet_res (or inet for that matter) that wants dual stack support would need to implement such a thing themself.

@RaimoNiskanen
Copy link
Contributor Author

RaimoNiskanen commented Mar 10, 2021

@RoadRunnr: I see!
Such a feature could actually use the same socket for both queries, so it is a different kind of parallelism. Feature parallel vs. server parallel.
EDIT:
Using a socket for both IPv4 and IPv6 is no longer come il faut, so that was a bad idea. :-(
EDIT AGAIN:
I should stop writing before coffee. Both the A and the AAAA query are against the same name server, so the same protocol (IPv4/IPv6), hence the same socket can be used; it was actually a good idea. :-)

@IngelaAndin IngelaAndin added the team:PS Assigned to OTP team PS label Mar 12, 2021
@RaimoNiskanen RaimoNiskanen marked this pull request as draft March 23, 2021 13:29
@IngelaAndin IngelaAndin added the stalled waiting for input by the Erlang/OTP team label Apr 27, 2021
@RaimoNiskanen RaimoNiskanen self-assigned this Jun 15, 2021
@IngelaAndin IngelaAndin added waiting waiting for changes/input from author and removed stalled waiting for input by the Erlang/OTP team labels Oct 5, 2021
@IngelaAndin IngelaAndin added stalled waiting for input by the Erlang/OTP team and removed waiting waiting for changes/input from author labels Sep 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stalled waiting for input by the Erlang/OTP team team:PS Assigned to OTP team PS
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants