Created
January 30, 2012 20:55
-
-
Save 0x8badf00d/1706637 to your computer and use it in GitHub Desktop.
Maximum simultaneous NSURLConnections
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
When connecting to a public HTTP server, a client should not maintain more | |
than two open connections to that server at one time. (RFC2616 §8.1.4) An | |
HTTP server is likely to impose its own limit on the number of simultaneous | |
connections from a single IP address anyway. Furthermore opening a large | |
number of simultaneous connections to a server may be seen as a denial of | |
service (DOS) attack upon the server. | |
Queuing HTTP 1.1 requests on a single, asynchronous connection such as | |
NSURLConnection is likely to offer the best throughput anyway - since both | |
the requests and the responses can be "pipelined" (sent back to back without | |
any pause between them). Furthermore, an asynchronous connection makes the | |
most effective use of the client's processor cycles; because it allows the | |
client to perform local processing (such as parsing HTML) more or less | |
continuously - and be interrupted only when data is available. | |
Generally, most HTTP requests are I/O bound - so transferring the data from | |
the server to the client's machine in the shortest amount of time achieves | |
the best performance. Client "load balancing" can only interfere with that | |
goal. And in fact a client has no reason for balancing the load of its | |
requests - because unlike a server - it can (and should) simply limit how | |
many outstanding requests it has to deal with at any one time. | |
Greg | |
http://lists.apple.com/archives/cocoa-dev/2006/Mar/msg01058.html |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment