Saturday 3 June 2017

node http requests not executed concurrently if made from same browser

var http = require('http');
http.createServer(function (req, res) {
    setTimeout(function () {
        res.write("hello");
        res.end();
    }, 10000);
}).listen(8080);

this is my simple node server running on localhost.

Now if i hit this url localhost:8080 from two different browsers simultaneously, i get response at same time on both browsers i.e after around 10 secs.
But on other hand when i do so from two different tabs of chrome browser, it takes 10 secs for one tab and another 10 secs for 2nd tab.

Seems like requests are being processed one after another rather than simultaneously.
can somebody explain?



via user1050008

No comments:

Post a Comment