Skip to content
Advertisement

PHP while loop to process faster , maybe with PHP worker implementation [closed]

I would like to get idea on how to process a while loop which consist of more than 3000 rows

JavaScript

Since the row of the result is huge and the while loop is taking around 1 hour to complete process it. Is there any suggestion to expedite the process?

I was thinking of having another PHP to spawn workers to process the CURL and UpdateDB part. Something like this :

JavaScript

Is it a good idea or is there any other ways to fulfill the following requirement using PHP or any other library?

In the curl command, i’ll be sending transactionID to a 3rd party API to get the status whether it’s fail or success. Latency is around 1-5 seconds

Advertisement

Answer

I think you have a few options now including @DarkBee’s exec('php ...' > /dev/null 2>/dev/null &'); and also curl_multi_init.

Here’s a quick example showing the time difference between initiating 100 requests using curl_multi_init Vs. the traditional curl_exec.

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement