Multiple https requests.. how to?

百般思念 提交于 2020-01-07 05:21:22

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!