Search code examples
phpmysqldnslong-running-processesdns-get-record

PHP script doing large amount of DNS queries - best way for handling it


I have a job that runs once in a week and retrieves a bunch of 700 hostnames. I need to translate those into IP adresses. My first experiment was calling the php native function "dns_get_record", storing the results into DB.

Due to the amount of dns queries to do, the script made my server freeze and, maybe the guys from DNS support thought it was getting attacked.

Now I'm thinking in spread this queries throughout 6 hours, maybe 12 after script startup. So I thought of making use of sleep(30) in the end of the foreach loop. Is it the best way to do this?

Do you have any other suggestion to make it lighter to my server and so to the DNS?

Thanks


Solution

  • save the last queried time to db and then query ur DNS list with using this list? of couse shell script will even be needed to run the php script like every 10 second etc. with that script u can check the last query time and if 30 seconds passed then remake your query etc...