开发者

Check image url multithreading

开发者 https://www.devze.com 2023-04-06 21:02 出处:网络
I am using PHP to check whether an image link is broken or not.Using PHP and cURL I can get the HTTP status code.However, it is taking a lot of time when checking millions of images.

I am using PHP to check whether an image link is broken or not. Using PHP and cURL I can get the HTTP status code. However, it is taking a lot of time when checking millions of images.

Is there any bette开发者_如何学运维r and faster ways of checking a large number of broken images?


Guessing the images are on a remote server...

Why not do it through a cronjob? Let it check every hour, and keep a database with files. If the file doesn't exist in the database, check it during the request.


you can't really multithread in php but you can emulate that using process control in php. You'll need a main php script and a worker script. The main script will have a reference to the images pool (the links) and will distribute the load across a number of worker scripts. The worker script is the one which will do the actual checking. After all the workers have done their job they will comunicate to main.php the result


how about using file_exists()?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号