Is PHP-CURL curl_multi_exec really multithreaded inside?

My question is very simple as indicated in the title. However, I will rephrase this again.

I want to download multiple sites using php-curl. I launched it from the console. I am going to use curl_multi_exec to load all sites. Now the question will hang to create different threads for each request?

I know that I can achieve this by spreading a few processes. But this is not a thread. I don't need a thread. I want to know if its multithreading?

+6
source share
1 answer

No. The multifunctional libcurl interface (which PHP uses for this work) executes several requests in parallel, but does so using non-blocking API calls. Not topics.

In past

(This section can now be considered historical, since libcurl is built by default using a multi-threaded resolver).

A problem that people may encounter is when a particular transfer must resolve the host name, since the standard host name recognition functions on most operating systems are synchronous, which causes each transformation to block all other transfers. This is overcome in libcurl by providing alternative resolver handlers, such as one created to use c-ares for resolution, and another that runs the "source resolver" in a separate thread - the so-called thread recognizer.

+13
source

Source: https://habr.com/ru/post/1391280/


All Articles