首页 \ 问答 \ 如何使用cURL无延迟地打开多个URL(How to open multiple URLs with cURL without delay)

如何使用cURL无延迟地打开多个URL(How to open multiple URLs with cURL without delay)

我想知道是否可以用cURL或其他东西打开多个URL。

我试过这个直到现在。

$urls = array(
          "http://google.com",
          "http://youtube.com",
          );

foreach($urls as $url) {
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_HEADER, false);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT,0);
    curl_setopt($ch, CURLOPT_TIMEOUT_MS, 200);
    curl_exec($ch);
    curl_close($ch);
}

200ms是让网站完全打开。 也许你知道任何其他选择。

是否可以同时在PHP中打开多个URL? 不是客户端,服务器端。


I was wondering if it's possible to open multiple URLs with cURL or maybe something else.

I tried this until now.

$urls = array(
          "http://google.com",
          "http://youtube.com",
          );

foreach($urls as $url) {
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_HEADER, false);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT,0);
    curl_setopt($ch, CURLOPT_TIMEOUT_MS, 200);
    curl_exec($ch);
    curl_close($ch);
}

The 200ms are there to let the site open fully. Maybe you know any alternatives.

Is it possible to open multiple URLs in PHP at the same time? Not client sided, server side.


原文:https://stackoverflow.com/questions/45172202
更新时间:2023-10-07 16:10

最满意答案

很高兴听到你现在获得更好的表现!

您的作业使用在托管代码中执行的表达式运行超过2800个非常小的文件,而不是转换为C ++,因为U-SQL中的一些更常见的C#表达式是。

这导致以下问题:

  1. 您可以使用一定数量的AU开始工作。 然后每个AU启动一个YARN容器来执行部分工作。 这意味着容器需要干净地初始化,这需要一些时间(您可以在顶点执行视图中将其视为创建时间)。 现在这需要一些时间,如果您的顶点执行大量处理,那就不会有太大的开销。 不幸的是,在你的情况下,在一个小文件上处理非常快,因此开销很大。

  2. 如果顶点只执行我们将代码生成到C ++代码中的系统生成的代码,那么我们可以在没有重新初始化时间的情况下重用容器。 遗憾的是,由于潜在的工件被遗忘,我们无法重用使用托管运行时执行的一般用户代码。 因此,在这种情况下,我们需要重新初始化容器,这需要花费时间(超过2800次)。

现在根据您的反馈,我们正在改进我们的重新初始化逻辑(如果您不使用内联C#表达式做任何事情,我们仍然可以重新初始化)。 此外,一旦我们可以在单个顶点内处理多个小文件而不是每个顶点一个文件,它会变得更好。

您的解决方法是增加文件的大小,并可能避免自定义代码(当然不总是可能)在太多顶点中。


Great to hear you are getting the better performance now!

Your job runs on over 2800 very small files using an expression that is being executed in managed code and not translated into C++ as some of the more common C# expressions in U-SQL are.

This leads to the following problem:

  1. You start your job with a certain number of AUs. Each AU then starts a YARN container to execute part of your job. This means that the container needs to be initialized cleanly which takes some time (you can see it in the Vertex Execution View as creation time). Now this takes a bit of time, that is not that much overhead if your vertex does some large amount of processing. Unfortunately in your case, the processing is very quick on a small file so there is a large overhead.

  2. If the vertex only executes system generated code that we codegen into C++ code, then we can reuse containers without the re-initialization time. Unfortunately, we cannot reuse general user-code that gets executed with the managed runtime due to potential artifacts being left behind. So in that case we need to re-initialize the containers which will take time (over 2800 times).

Now based on your feedback, we are improving our reinitialization logic (we can still reinitialize if you do not do anything fancy with inline C# expressions). Also, it will get better once we can process several small files inside a single vertex instead of one file per vertex.

Workarounds for you is to increase the sizes of your files and to possibly avoid custom code (not always possible of course) to be in too many of the vertices.

相关问答

更多
  • 这么晚才回复很抱歉。 任何说明它是系统错误( E_SYSTEM )的错误都应该升级并作为调查事件归档。 Sorry for the late reply. Any error that says that it is a system error (E_SYSTEM) should be escalated and filed as an incident for investigation.
  • 这是另一种方式。 我使用示例中的SearchLog.tsv来演示这一点。 在文件的顶部,我添加了从01JAN17 TO 31JAN17的行。 //Skip the first row and read all the other rows @searchlog = EXTRACT UserId int, Start DateTime, Region string, ...
  • 使用“ 偏移”属性可能会有点混乱,因为您需要在数据集级别重新设置时间片。 作为替代方案,我建议在活动中使用Delay属性。 这提供了更多控制,并且不需要重新配置时间片。 所以在你的JSON中...... { "name": "filtering", "properties": { "activities": [ { "type": "DataLakeAnalyticsU-SQL", "typeProperties": { ...
  • 我会将您的工作链接转发给我们的开发人员,他们可以查看并在获得更多信息后更新此答案。 但是,对于stackoverflow帮助,查看脚本和/或作业图也会很有帮助。 例如,您运行了多少数据? 您使用的是暗示订购或分组等的操作吗? 基于顶点执行视图,您似乎从许多小文件中提取每个文件只包含少量数据。 很可能优化器假定只有少量数据来自这些文件。 您可以向EXTRACT语句添加一个OPTION(ROWCOUNT= xxx)提示,以提示更多行( xxx将是强制系统并行化的数字),假设我的初始假设是正确的。 查看工作后的一 ...
  • 你只需将它传递给提取器,如下所示: @searchlog = EXTRACT UserId int, Start DateTime, Region string, Query string, Duration int?, Urls string, ClickedUrls strin ...
  • 可能你必须自己管理创建和注册程序集,作为你工作中的一个额外步骤。 然后像通常那样参考组件。 如果您需要一个可能的样例,请从Visual Studio提交一份作业,查看具有伴随代码隐藏文件的查询,并查看它为您生成的脚本。 你会看到它透明地为你添加上述步骤。 现在,您可以尝试在自己的代码中应用相同的方法/模式。 或者将您的代码隐藏逻辑移动到专用库,您可以一次性上传并单独注册,然后将其引用到您的Python提交作业中的心脏内容。 Once compiled, the DLL file for your code ...
  • 你在使用Outputters.Csv输出器吗? 使用以下参数: ... USING Outputters.Csv(outputHeader:true); 这将输出行集的列名作为列标题行。 Are you using the Outputters.Csv outputter? Use the following argument: ... USING Outputters.Csv(outputHeader:true); That will output the column names of the ro ...
  • 很高兴听到你现在获得更好的表现! 您的作业使用在托管代码中执行的表达式运行超过2800个非常小的文件,而不是转换为C ++,因为U-SQL中的一些更常见的C#表达式是。 这导致以下问题: 您可以使用一定数量的AU开始工作。 然后每个AU启动一个YARN容器来执行部分工作。 这意味着容器需要干净地初始化,这需要一些时间(您可以在顶点执行视图中将其视为创建时间)。 现在这需要一些时间,如果您的顶点执行大量处理,那就不会有太大的开销。 不幸的是,在你的情况下,在一个小文件上处理非常快,因此开销很大。 如果顶点只执 ...
  • 由于文件大于250MB,因此您需要确保将其上载为面向行的文件而不是二进制文件。 此外,请检查以下问题的回复,以了解您目前如何找到有关错误的更多详细信息: 调试u-sql作业 Since the file is larger than 250MB, you need to make sure that you upload it as a row-oriented file and not a binary file. Also, please check the reply for the followin ...
  • 您可以使用BETWEEN子句并将fileDate虚拟列与指定的日期进行比较来实现解决方案,例如, DECLARE @ProcessStart DateTime = new DateTime(@sliceEndTime.Year, @sliceEndTime.Month,@sliceEndTime.Day).AddDays(-n); // n is the no of days DECLARE @ProcessEnd DateTime = new DateTime(@sliceEndTime.Year, @ ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。