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
Async example? #111
Comments
Apologies for the (very) late reply, this issue slipped under my radar. To perform multiple queries simultaneously (or multiple of any operation which will await I/O), use $listOfDomains = [...]; // List of domain names to query.
$futures = [];
foreach ($listOfDomains as $domain) {
$futures[$domain] = Amp\async(Dns\resolve(...), $domain);
}
$resolvedRecords = Amp\Future\await($futures); Note it may not be a good idea to initiate 500 DNS requests simultaneously. As with many simultaneous async operations, it may be a good idea to throttle the number of simultaneous requests in-flight. See amphp/sync and amphp/pipeline for tools to do just this. |
Can you please share a link to example of async dns query loop of 500 domains for example.
Of course, simply changing
Dns\resolve($domain)
in/examples/benchmark.php
to:doesn't make any difference.
The text was updated successfully, but these errors were encountered: