1. Tp framework with querylist using CurlMulti plug-in multithreaded execution appears after a period of time
2. There is a large amount of data in the environment php nginx mysql (the original apache, is always used on the server 500, and the code timeout is set, so switch nginx if you can"t)
3, related codes
/ / Please paste the code text below (do not replace the code with pictures)
as follows. If this url 404 will not be executed later, in fact, I added judgment
public function makeids()
{
$index = input("param.index");//id
$last = input("param.last");//id
set_time_limit(3600);
$urlmake = [];
$ql = QueryList::getInstance();
for ($i = $index; $i <=$last; $iPP) {
for ($j = $i . "000"; $j <= $i . "999"; $jPP) {
if (ISCESHI){
$url = LOCALURL."/index.php/index/index/getlists/id/" . $i . "_" . $j;
}else{
$url = SERVICE."/index.php/index/index/getlists/id/" . $i . "_" . $j;
}
$urlmake [] = $url;
if(count($urlmake)>=5){
$ql->use(CurlMulti::class);
$ql->curlMulti($urlmake)
->success(function (QueryList $ql, CurlMulti $curl, $r) {
echo "Current url:{$r["info"]["url"]} \r\n";
// if (!empty($r)){
$this->getlists($r["info"]["url"]);
// }
unset($urlmake);
$ql->destruct();
})
->start([
//
"maxThread" => 1999,
// curl$error
"maxTry" => 3,
// CURLOPT_*
"opt" => [
CURLOPT_TIMEOUT => 3600,
// CURLOPT_CONNECTTIMEOUT => 1,
CURLOPT_CONNECTTIMEOUT => 0,
CURLOPT_RETURNTRANSFER => true
],
// url
"cache" => ["enable" => false, "compress" => false, "dir" => null, "expire" => 86400, "verifyPost" => false]
]);
}
}
}
}
when the collection result is not empty here
$result = $data->all();
if (!empty($result)) {
xx
}