问题
I have an https API URL which I need to run multiple times, and as quickly as possible to check the status of a domain.
How can I run the same URL multiple times concurrently, while receiving the response in output, and closing the finished connection, whilst also keeping memory resources as low as possible?
I was told to use threading in another language (not PHP)?
Any examples or lending hand would be greatly appreciated! Thanks
回答1:
Just did a quick google and came up with this, I believe this will solve your problem - this quote sums it up:
Using the curl_multi* family of cURL functions you can make those requests simultaneously. This way your app is as slow as the slowest request, as opposed to the sum of all requests.
回答2:
m.edmondson was faster than me :D
An maybe helpful information: When doing a lot requests with curl simultaniously, you'll probably get a time lag bcs the curl DNS resolver doesn't work concurrently.
As an alternative idea you could write an php cli script which forks childs who work seperately, or just use bash & lynx (on linux).
来源:https://stackoverflow.com/questions/4579440/multiple-https-requests-how-to