Gabriel Bianconi Gabriel Bianconi - 4 months ago 15
PHP Question

Fastest way to ping thousands of websites using PHP

I'm currently pinging URLs using CURL + PHP. But in my script, a request is sent, then it waits until the response comes, then another request, ... If each response takes ~3s to come, in order to ping 10k links it takes more than 8 hours!

Is there a way to send multiple requests at once, like some kind of multi-threading?

Thank you.

Answer

You can either fork your php process using pcntl_fork or look into curl's built-in multi-threading. https://web.archive.org/web/20091014034235/http://www.ibuildings.co.uk/blog/archives/811-Multithreading-in-PHP-with-CURL.html