36

I'm currently using Curl for PHP a lot. It takes a lot of time to get results of about 100 pages each time. For every request i'm using code like this

$ch = curl_init();

// get source

curl_close($ch);

What are my options to speed things up?

How should I use the multi_init() etc?

1

4 Answers 4

48
  • Reuse the same cURL handler ($ch) without running curl_close. This will speed it up just a little bit.
  • Use curl_multi_init to run the processes in parallel. This can have a tremendous effect.
Sign up to request clarification or add additional context in comments.

1 Comment

I now use a curl_multi_init for about 10 requests at a time. Takes about 5 for 10 requests =D
8

take curl_multi - it is far better. Save the handshakes - they are not needed every time!

Comments

1

when i use code given in "http://php.net/curl_multi_init", response of 2 requests are conflicting. But the code written in below link, returns each response separately (in array format) https://stackoverflow.com/a/21362749/3177302

Comments

0

or take pcntl_fork, fork some new threads to execute curl_exec. But it's not as good as curl_multi.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.