PHP cURL multithreading without curl_multi, how to?

467 views Asked by At

I know it's most likely a very dumb question to ask, and I've been using curl_multi and classes such as https://github.com/petewarden/ParallelCurl/ for multithreading.

But recently I came across this building a web proxy, an open-source PHP web proxy framework called glype.

it seems to me all resources are fetched by cURL, and there's no curl_multi in its source code whatsoever, the code contains only curl_init and curl_exec.

That said, img's (and probably other src too) load concurrently, I briefly went through the code, but failed to find a clue how it works this way.

Anyone have tried multithreading cURL without using curl_multi? (PHP pthread not included)

1

There are 1 answers

0
Joe Watkins On BEST ANSWER

cURL Multi has nothing whatever to do with multi-threading, or parallelism.

cURL Multi is a set of functions within the cURL extension that use non-blocking I/O for asynchronous execution of requests.

To be clear, cURL Multi is not parallel, nor multi-threaded: It facilitates non-blocking asynchronous I/O.

Glype uses the processing model of the server serving the code: When your browser requests a page through Glype, the server is responsible for creating (or reusing) the process that executes Glype. In the same way, when the page requests resources like CSS or images from the server, it is the server that creates (or re-uses) a process, which in turn executes the PHP interpreter, which in turn executes Glype.