Maximum # Simultaneous Downloads with NSURLSession Regardless of Host

吃可爱长大的小学妹 提交于 2019-12-11 04:32:08

问题


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.

Regardless I assume it's ridiculous to expect more than 2 or 3 at once..

Edit

Assuming the ability to have as many hosts and NSURLSession instances as wanted


回答1:


You can set more than 1000. As you know, Apples's document doesn't specify upper limit.

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.).



来源:https://stackoverflow.com/questions/45092786/maximum-simultaneous-downloads-with-nsurlsession-regardless-of-host

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