php - How to send multiple requests in one curl open connection


i have an array with approximately 45 k usernames in in i want to hit a url using curl that would give me a response pertaining to those usernames.The issue is i want to achieve it in less time.

$username=['123','456','789'....] //upto 45k entries
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, ''.$username[$i]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
curl_setopt($ch, CURLOPT_USERAGENT, $ua);
curl_setopt($ch, CURLOPT_AUTOREFERER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_MAXREDIRS, 20);
curl_setopt($ch, CURLOPT_HTTPGET, true);
$result = curl_exec($ch); 

The above code depicts what i am doing right now but as usernames are in large numbers it takes alot of time to return all the responses.Is there any way i can achieve it in less time.




Have a look at , it speeds up our curl requests a lot.

It has multi-curl support enabled and it's very easy to use.

As for your question on the time, you can set the time out using


Or in the case of MultiCurl


You can extend the timeout as much time as needed.




You can use curl-multi-init and curl-multi-exec so that your requests are processed asynchronously.

People are also looking for solutions to the problem: php - Symfony FOSUserBundle : keep other forms' data after login


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.