Skip to content

Commit

Permalink
Tidy up documentation.
Browse files Browse the repository at this point in the history
  • Loading branch information
ioquatix committed Jul 23, 2024
1 parent 789526d commit 5e923c3
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 61 deletions.
64 changes: 4 additions & 60 deletions guides/getting-started/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,10 @@ $ bundle add async-dns
Here is a simple example showing how to use the resolver:

``` ruby
Async do
resolver = Async::DNS::System.resolver

addresses = resolver.addresses_for("www.google.com.")

puts addresses.inspect
end
# [#<Resolv::IPv4 202.124.127.240>, #<Resolv::IPv4 202.124.127.216>, #<Resolv::IPv4 202.124.127.223>, #<Resolv::IPv4 202.124.127.227>, #<Resolv::IPv4 202.124.127.234>, #<Resolv::IPv4 202.124.127.230>, #<Resolv::IPv4 202.124.127.208>, #<Resolv::IPv4 202.124.127.249>, #<Resolv::IPv4 202.124.127.219>, #<Resolv::IPv4 202.124.127.218>, #<Resolv::IPv4 202.124.127.212>, #<Resolv::IPv4 202.124.127.241>, #<Resolv::IPv4 202.124.127.238>, #<Resolv::IPv4 202.124.127.245>, #<Resolv::IPv4 202.124.127.251>, #<Resolv::IPv4 202.124.127.229>]
resolver = Async::DNS::System.resolver

resolver.addresses_for("www.google.com.")
# => [#<Resolv::IPv4 172.217.167.100>, #<Resolv::IPv6 2404:6800:4006:809::2004>]
```

### Server
Expand Down Expand Up @@ -54,55 +50,3 @@ server.run
Then to test you could use `dig` like so:

dig @localhost -p 5300 google.com

## FAQ

### File Handle Limitations

I get the error `Errno::EMFILE: Too many open files - socket(2) - udp` when trying to run a server. What should I do?

On some platforms (e.g. Mac OS X) the number of file descriptors is relatively low by default and should be increased by calling `ulimit -n 10000` before running tests or even before starting a server which expects a large number of concurrent incoming connections.

### Server

The performance is on the same magnitude as `bind9`. Some basic benchmarks resolving 1000 names concurrently, repeated 5 times, using `Async::DNS::Resolver` gives the following:

```
user system total real
Async::DNS::Server 4.280000 0.450000 4.730000 ( 4.854862)
Bind9 4.970000 0.520000 5.490000 ( 5.541213)
```

These benchmarks are included in the unit tests. To test bind9 performance, it must be installed and `which named` must return the executable.

## Performance

We welcome additional benchmarks and feedback regarding Async::DNS performance. To check the current performance results, consult the [travis build job output](https://travis-ci.org/socketry/async-dns).

### Resolver

The `Async::DNS::Resolver` is highly concurrent and can resolve individual names as fast as the built in `Resolv::DNS` resolver. Because the resolver is asynchronous, when dealing with multiple names, it can work more efficiently:

```
user system total real
Async::DNS::Resolver 0.020000 0.010000 0.030000 ( 0.030507)
Resolv::DNS 0.070000 0.010000 0.080000 ( 1.465975)
```

These benchmarks are included in the unit tests.

### Server

The performance is on the same magnitude as `bind9`. Some basic benchmarks resolving 1000 names concurrently, repeated 5 times, using `Async::DNS::Resolver` gives the following:

```
user system total real
Async::DNS::Server 4.280000 0.450000 4.730000 ( 4.854862)
Bind9 4.970000 0.520000 5.490000 ( 5.541213)
```

These benchmarks are included in the unit tests. To test bind9 performance, it must be installed and `which named` must return the executable.

### DNSSEC support

DNSSEC is currently not supported and is [unlikely to be supported in the future](http://sockpuppet.org/blog/2015/01/15/against-dnssec/). Feel free to submit a PR.
1 change: 1 addition & 0 deletions lib/async/dns/endpoint.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

module Async
module DNS
# DNS endpoint helpers.
module Endpoint
# Get a list of standard nameserver connections which can be used for querying any standard servers that the system has been configured with.
def self.for(nameservers, port: 53, **options)
Expand Down
2 changes: 1 addition & 1 deletion lib/async/dns/resolver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ def dispatch_query(name, resource_class)
end

# Send the message to available servers. If no servers respond correctly, nil is returned. This result indicates a failure of the resolver to correctly contact any server and get a valid response.
def dispatch_request(message, parent: Async::Task.current)
def dispatch_request(message)
request = Request.new(message, @endpoint)
error = nil

Expand Down

0 comments on commit 5e923c3

Please sign in to comment.