Re: NSURLRequest/connection timing
Re: NSURLRequest/connection timing
- Subject: Re: NSURLRequest/connection timing
- From: Mark Pauley <email@hidden>
- Date: Wed, 14 Sep 2011 14:13:01 -0700
On Sep 14, 2011, at 1:19 PM, lcerveau wrote:
> Hi
>
> I have a question regarding time a NSURLRequest/NSURLConnection is taking and the internal of it. I already asked to cocoa-dev but was advise to ask on this one.
>
> I do the following
>
> - When creating/launching the request I take a timestamp,
> - in the delegate method
> - (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response
> I take another one. I have results like 0.6 seconds.
>
> I have to launch multiple request at nearly the same time to the server (like 20)
>
> - At the same time I use a software like HTTPScoop to look on how it is timing all this. Time are always différent like 0.05 seconds.
> So nearly always a factor of like 10.
>
> Who to believe on the time it takes?
Does HTTPScoop (or even better, try WireShark) tell you the time between when the TCP SYN is sent to the remote host and when response header bytes come in? Typically in your situation, the latency incurred in opening the connection is not a negligible piece of time. NSURLConnection should keep the connection open between requests, provided that you don't idle the network connection. In your case, that means that some requests will seem to be very quick because they're using a connection opened for them by a previous request.
>
> As all the requests are against the same server and this one is supporting the use of setHTTPShouldUsePipelining. But it seems not to provide any speed gain and looking at the result I have the feeling requests are send before the previous one returns, that the server answers correctly but that the low level implementation of NSURLRequest/NSURLConnection is delivering them one after the other loosing the benefit of pipelining. Or do I miss a part here?
NSURLConnection opens new connections to the maximum number of simultaneous TCP connections per host ( typically something like 6 ) before pipelining. If you feel that you need fewer than this in order to take advantage of HTTP pipelining, please file a feature request for API to allow you to lower this value (for example to 1 connection per host).
_Mark
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden