Curl multiple processes cycle http requests take up a lot of cpu, how to optimize it

when PHP uses queues to send text messages and mail in batches, curl http loops request Ali takes up a lot of cpu when the request Ali is larger than the interface, resulting in slow website access. In this case, how to optimize it


curl request sets timeout, response time, and discards if the time is too long.
and. The number of concurrent requests can be less at the same time. If you now have 100 text messages waiting to be sent in the library, you can't take them out at once and then foreach the loop. You can take 10 at a time. And then deal with it. After processing, pick it up again and send it again. This way of thinking. You can try it. The same is true of e-mail.


curl_multi_init processes batch cURL in parallel
http://php.net/manual/zh/func.

Multi-threaded CURL, is very suitable for your current batch processing scenario.

Menu