多大的缓冲区最适合将文件上传到互联网
我正在使用 MS 提供的 HTTP API 将视频上传到 YouTube,我注意到不同的缓冲区大小所花费的总时间是不同的,什么大小的缓冲区最适合将文件上传到互联网?提前致谢。
I'm using HTTP API provided by MS to upload video to YouTube, I noticed the total elapsed time is different with different buffer size, what size of buffer is the best for uploading file to internet? Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试一下。取决于您的网络速度和其他设置。如果有一个最佳大小,它就会被预先配置。
Try it out. Depends on your network speed and other settings. If there would be the one optimal size, it would have been preconfigured.
正确的一个?
TCP/IP 具有许多内置的自调整功能(尽管默认情况下禁用窗口缩放)。如果您使用不同的应用程序级别缓冲区看到不同的行为,那么这很可能是由于应用程序代码中的异常造成的。如果代码是闭源的,那么您只能进行黑盒测试来找到最佳行为。然而,猜测听起来源读取被延迟,直到缓冲区为空 - 尝试使用带有预取的旋转缓冲区,例如
i) 将 X 字节读入缓冲区 1
ii) 开始将缓冲区 1 写入单独线程中的输出
iii) 将 X 个字节读入缓冲区 2
iv) 当 ii 中创建的线程返回时,交换缓冲区并重复 ii
C中的步骤。
The right one?
TCP/IP has lots of self-tuning functionality built in (although by default window scaling is disabled). If you are seeing different behaviours using different application level buffers then this is most likely due to anomolies within the application code. If the code is closed-source then you can only ever do black box testing to find the optimal behaviour. However at a guess it sounds like the source reads are delayed until the buffer is empty - try using rotating buffers with a pre-fetch, e.g.
i) read X bytes into buffer 1
ii) start writing buffer 1 to the output in a seperate thread
iii) read X bytes into buffer 2
iv) when the thread created in ii returns, swap the buffers around and repeat steps from ii
C.