Search code examples
phpperformanceiphostresolve

PHP fastest way to check list of domains


I have a list of 20.000 domains I want to resolve into IP addresses. I am looking for the fastest way to do that in php.

I used gethostbynamel() but that is too slow. I am looking for another command that can filter out the hosts that do not exist at all and then run gethostbynamel()

  1. I have tried checkdnsrr("host.com","A") but that is too slow.
  2. curl is also too slow.

Solution

  • It won't get any faster. You'll have to contact each domain to see if they're available. Even with an avarage roundtriptime of about 50ms you will need more that 15 minutes to check out all 20000 domains. And that is if you don't have to wait for time-outs.

    You will only get faster if you make this multi-threaded. You can easily setup 10 threads to connect to 10 servers in parallel, which cuts the processing time in 10 too.

    But PHP is not really designed for multi threading, so you might want to use another tool.

    But why on earth do you want to check out 20.000 domains? It must be something fishy..