There are all sorts of things that could cause this behavior.  A couple 
significant ones:  If you have an extremely high number of max sockets, 
that means every request makes a socket, and no connection pooling is going 
on.  If your connections are https, that's going to add a humongous amount 
of overhead dwarfing anything else (whereas if you're using only 100 
connections and pooling them you pay that overhead once, and then get a lot 
of quick requests sent over the same connection).  Also, if your actual 
test is using https/ssl, just the local CPU usage of opening thousands of 
connections (which, I suspect only happens in one thread per node process) 
could explain some of it.

If you're actually testing this on a 3rd party server (like google.com in 
your example), then their load balancing and DDoS configuration of their 
network comes into play.  For example, if they have a limit of how many 
active connections per source IP get through some layer of their incredibly 
complicated and heavily layered network topology, even if your computer 
tries to open 1000 TCP connections at once, all but the first handful will 
just have to wait on the other end.

As for the specifics of your examples, your numbers sound just as expected 
- with default of 5 max sockets, parallelism is 5, with a request time of 
around 100ms, 1000 requests will take about 20000ms.  On the box I'm 
currently on (OSX, node 0.10.25), if I increase http.globalAgent.maxSockets 
to 1000 (each one gets its own socket, which I can verify in netstat, if 
I'm quick), I see it takes about 60ms just to issue the 1000 requests 
(timing before and after calling async.each), and then the first request to 
come back has a total response time of about 170ms, the last one comes back 
in about 730ms, so I'm not seeing the slowdown you're seeing, which sounds 
like it may just be something on your end throttling requests (could be OS 
issue, router issue, ISP issue, or any number of things between your and 
www.google.com).

Also of note, running node with "time", only about 20% of the time is idle 
(e.g. most of the time is spent in node on my own local machine, presumably 
the overhead of creating new connections, etc, which is done in serial, not 
waiting for responses to come back, which is what happens in parallel).

Also of note, in the time I ran these tests and wrote this email, I think 
Google's network has now flagged my IP as a possible DoS attack, and now it 
looks like I'm getting throttled and everything is taking quite a bit 
longer than it was when I first ran the test.  If you truly want to test 
node, you need to be hitting a server which you control and know the 
performance characteristics of, otherwise you may not be testing what you 
think you're testing.

  Jimb Esser


On Tuesday, April 14, 2015 at 7:05:24 AM UTC-7, Kishore Kumar Yekkanti 
wrote:
>
> In my original code i had a callback, missed it in this sample codebase. 
> That said the issue was not with the callback at least in my case. Its 
> because of the maxSockets of http node library. I'm using node 0.10 and as 
> part of the spec its mentioned that max of 5 socket connections can be 
> connection pooled. i bumped up this number to 100 and i can see faster 
> response times.  
>
> But one question still remains, when i bump up this number to something 
> extremely higher like 999999, it fallsback to the default behaviour and the 
> response time increases. I guess it could be my hardware limit also. 
> Nevertheless i'll look into the http codebase to understand this behaviour 
> in specific. 
>
> On Saturday, April 11, 2015 at 12:50:35 AM UTC+5:30, Marcos Mendez wrote:
>>
>> I think so to..
>>
>> function(item, callback) {
>>             callExternalUrl();
>>         },
>>
>> callback never gets called.
>>
>> On Tuesday, April 7, 2015 at 11:43:36 PM UTC-4, kodamatic wrote:
>>>
>>> Missing call callback? 
>>>
>>

-- 
Job board: http://jobs.nodejs.org/
New group rules: 
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/nodejs/9c2c1fcc-3ae2-45ec-a723-9ca8c908c983%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to