14 ms·
The 'Hello World' example (at the top of the front page of the Node.js website) is a server that listens to http requests, waits 2 seconds, then responds 'Hello
by ra88it 17y ago
The 'Hello World' example (at the top of the front page of the Node.js website) is a server that listens to http requests, waits 2 seconds, then responds 'Hello World'.
The server is supposed to continue responding to incoming requests even while it is waiting 2 seconds for previous requests. So I figured that if I quickly queued up a bunch of requests (say, over the course of one second), they would all respond just as quickly after the two seconds was up.
However, each response came a full 2 seconds after the previous response. I increased the wait argument to 10 seconds just to be sure.
This seems functionally equivalent to blocking. Is this the way the example is supposed to work?
- simonw 17y agoWas your client sending the requests concurrently? If I do that and run "ab -n 100 -c 100" (for 100 requests run with concurrency 100) the benchmark takes almost exactly 2 seconds to execute all 100 requests.
- ra88it 17y agoI guess not - it worked when I followed your suggestion. Thanks! I was naively cranking out a bunch of tabs in Firefox really quickly. :) I guess Firefox doesn't make concurrent requests when it's the same URL...?
- pilif 17y agoFirefox only makes two (by now maybe four) concurrent requests to the same server as mandated by the HTTP protocol.
- pmjordan 17y agoIt's technically not mandated, but recommended. Servers need to be able to deal with more anyway, as proxy servers are recommended to open up to 2 * [no of clients] connections to upstream servers.
- simonw 17y agoFirefox has a maximum of 2 connections per host - though it's being upped to 6 in Firefox 3.5.