Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maximize the number of simultaneous http-downloads

I'am trying to perform as many as possible simultaneous http-downloads an IPad2 ( ios6.0 ). This is pure for testing what is possible on this device. Even not interested in GUI performance ( not important if it doesn't respond )

I've created a special HTTP-server that sends for x minutes data to the client. The data received is of no importance. I just measure the speed an how many concurrent downloads. I've implemented 2 different ways of scheduling 12 HTTP-requests.

NSOperation

One is done by using NSOperation objects in a Queue and set the NSOperationQueueDefaultMaxConcurrentOperationCount on 12

NSThread

The second implementation is by creating 12 NSThreads that perform a synchro http-request.

The requests are all sent to the same destination IP.

Observation

What I observe is that in both cases the 6th to 12th request get a TimeOut ( errorcode -1001 ). If 1 put the timeout-value to 80.0 seconds, I see that the 6th download starts when the 1st is done.

Questions

  • Is there in IOS a limit on how many concurrent downloads?
  • Is there an other way to perform these concurrent downloads ?
  • Is there a way to bind a thread to a core ( so that it doesn't get an interrupt, like cpuaffinity in C++ ) or thread priority
like image 740
Wouter Debie Avatar asked Feb 26 '13 12:02

Wouter Debie


2 Answers

Just a bump to this in case anyone is still looking. I see it to be 4 simultaneous on my iPhone6S+. Here were my test steps:

  • I wrote a PHP script that does sleep(10) before echoing something back.
  • I added a button (so I can execute well after startup)
  • Hitting that button triggers 30 simultaneous NSURLConnections (synchronous requests, but each in a separate thread), and an NSLog.
  • The completion for each does an NSLog

The results are like clockwork. The first responses (4 of them) come back 12 seconds after the request (presumably 2 seconds to turn the radio on or whatever), but then each subsequent block of 4 responses come 10 seconds after the prior block of 4. All 4 at a time.

Hope that helps someone.

like image 188
Paul Avatar answered Sep 19 '22 15:09

Paul


You can have maximum of 5 simultaneous connections to the same server. It's an iOS fixed limit and it's probably because of some http protocol constraints. You can read a bit more info here.

like image 45
graver Avatar answered Sep 22 '22 15:09

graver