c++ - curl 停止在 Linux 上使用多个连接进行下载

标签 c++ linux curl download multiprocessing

我在使用 curl 时遇到问题,从版本 1.28.1 到 1.37.1 - 出现同样的问题: 在 Linux 环境中,使用命令行,我同时运行以下命令:

curl -o /dev/null "http://example.com/short_video.mp4" -o /dev/null "http://example.com/short_video.mp4" &
curl -o /dev/null "http://example.com/short_video.mp4" &
curl -o /dev/null "http://example.com/short_video.mp4" &
curl -o /dev/null "http://example.com/short_video.mp4" &

问题是 - 它开始成功下载,但通常在高速互联网连接上,其中一个下载卡在零速度上,整个过程都卡住了。 唯一有帮助的是使用速度限制:

curl --speed-limit 5 -o /dev/null "http://example.com/short_video.mp4" &

然后它识别出速度低并终止下载,但我首先想知道如何避免这种情况。

最佳答案

经过一个小的研究,似乎它有时会发生在任何一个连接上,(即使没有使用多个连接) 这似乎是 TCP 流量控制中的一个错误,称为:愚蠢的窗口综合症: https://en.wikipedia.org/wiki/Silly_window_syndrome

引用:

A serious problem can arise in the sliding window operation when the sending application program creates data slowly, the receiving application program consumes data slowly, or both. If a server with this problem is unable to process all incoming data, it requests that its clients reduce the amount of data they send at a time (the window setting on a TCP packet). If the server continues to be unable to process all incoming data, the window becomes smaller and smaller, sometimes to the point that the data transmitted is smaller than the packet header, making data transmission extremely inefficient.

我注意到在很长一段时间(2 分钟或更长时间)后它再次开始下载。

关于c++ - curl 停止在 Linux 上使用多个连接进行下载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29192920/

相关文章:

php - 使用带有 php 的 Google 驱动器可恢复上传

c++ - 在线程之间 move vector

c++ - 在 Qt 中,如何正确实现委托(delegate)?

c++ - 调用可变类型的静态 constexpr 数组时 undefined reference

c++ - 在当前类的构造函数中调用其他类定义的虚函数

linux - korn shell 脚本失败

linux - xmonad xmodmap 将选项卡更改为 alt gr 但它不适用于 firefox 或 Thunderbird

linux - 如何找到可用于特定虚拟到物理地址映射的最大页面大小?

iis - 将 Base64 CSR 提交给 Microsoft CA(通过 cURL)

curl - 如何使用 Curl POST 到 configSubmit Jenkins 页面