Adam Hopkinson
Adam Hopkinson

Reputation: 28795

How many threads does curl_multi_exec use?

I'm using curl_multi_exec in php to check the status of a number of URLs. I want to benchmark this so that, for a given system, I know how many handlers I can check synchronously before curl starts queuing. Does anyone have any experience on how to gauge capacity?

Thanks,

Adam

Upvotes: 3

Views: 2556

Answers (1)

Ivo Danihelka
Ivo Danihelka

Reputation: 3412

You can see from PHP source code that it uses select() and non-blocking reads. So only one process is used.

Note that select() will fail, if you give it a file descriptor with fd >= FD_SETSIZE. The FD_SETSIZE limit is defined when compiling PHP. The default seems to be 256. It would be better to use poll() in the PHP implementation.

About correct curl_multi_exec() usage:

curl_multi_exec() should be followed by curl_multi_select(). That will wait for available data, instead of checking them in a busy loop. The example in the PHP manual is good.

Upvotes: 2

Related Questions