无论主机如何,使用 NSURLSession 的最大同时下载数 [英] Maximum # Simultaneous Downloads with NSURLSession Regardless of Host
问题描述
我知道 NSURLSessionConfiguration
上的 HTTPMaximumConnectionsPerHost
选项...但是不管主机如何,iOS 可以处理多少个连接?
I know about the HTTPMaximumConnectionsPerHost
option on NSURLSessionConfiguration
... but how many connections can iOS handle irrespective of host?
我认为这取决于...核心数量...网络接口...以及操作系统的总体繁忙程度+其他应用程序的下载.
I assume this depends on some combination of... the # of cores.. the network interface.. and how busy the OS is in general + with downloads for other applications.
找不到关于此的任何提示.
Can't find any hints about this.
尽管我认为一次超过 2 或 3 个是荒谬的..
Regardless I assume it's ridiculous to expect more than 2 or 3 at once..
编辑
假设能够拥有尽可能多的主机和 NSURLSession 实例
Assuming the ability to have as many hosts and NSURLSession instances as wanted
推荐答案
可以设置1000多个.众所周知,Apples的文档没有规定上限.
You can set more than 1000. As you know, Apples's document doesn't specify upper limit.
为了在后台下载大约2000个小文件,我将httpMaximumConnectionsPerHost设置为2000,并在WiFi下使用iPhone7+/iOs10.3.1进行了测试.它没有任何问题.然后,我通过更改来测试下载时间httpMaximumConnectionsPerHost,并意识到增加数量不一定会购买下载时间.所以,现在,我将其保留为默认值 (=4).我认为您需要检查您的应用(文件数量、大小等).
To download about 2000 small files in background, I set httpMaximumConnectionsPerHost to 2000, and tested w/ iPhone7+/iOs10.3.1 under WiFi. It worked w/o any issue. Then, I tested download time by changing httpMaximumConnectionsPerHost, and realized that increasing the number doesn't necessarily buy download time. So, for now, I'm leaving it to default value (=4). I think you need to examine with your apps (number of files, size, etc.).
这篇关于无论主机如何,使用 NSURLSession 的最大同时下载数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!