title: Concurrent vs Serial Queue for executing large number of Server requests in iOS
body: <p>If an iOS app has to make hundreds of server requests in background and save the result in local mobile database, which approach would be better in terms of performance (less crashes)?</p>
  
  <p>Passing all requests as 1 block in Global Background Queue</p>
  
  <pre><code>dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), ^{
      for (i=0;i&lt;users;i++)
        {
          Call Api 1
          Call Api 2
          Call Api 3
        }
  });
  </code></pre>
  
  <p>OR</p>
  
  <p>Creating 'n' number of User Serial Queues and adding all 3 api calls as individual blocks in each serial queue.</p>
  
  <pre><code>for (i=0;i&lt;users;i++)
  {
      dispatch_queue_t myQueue = dispatch_queue_create([[users objectAtIndex:i] UTF8String], DISPATCH_QUEUE_SERIAL);
                dispatch_async(myQueue, ^{
                     Call Api 1
                  });
                dispatch_async(myQueue, ^{
                     Call Api 2
                  });
                dispatch_async(myQueue, ^{
                     Call Api 3
                  });
  }
  </code></pre>
  
  <p>Edit: In each <strong>Call Api</strong>, I am using <strong>NSOperationQueue</strong>. </p>
  
  <pre><code>queue = [[NSOperationQueue alloc] init];
  [NSURLConnection sendAsynchronousRequest:request queue:queue completionHandler:^(NSURLResponse *response, NSData *data, NSError *error) {..}
  </code></pre>