Created
July 1, 2013 02:38
-
-
Save bingeboy/5898024 to your computer and use it in GitHub Desktop.
Loop for GET requests.
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
var http = require('http'); | |
var pool = require('generic-pool').Pool({ | |
name : 'http_request', | |
create : function(callback) { | |
var c = http.createClient(80, '127.0.0.1'); | |
callback(null, c); | |
}, | |
destroy : function(client) { }, | |
max : 10, | |
idleTimeoutMillis : 300, | |
log : false | |
}); | |
for(var i = 0; i < 200000; i++) { | |
pool.acquire(function(err, client) { | |
var request = client.request("GET", '/'); | |
request.end(); | |
request.on('response', function(response) { | |
console.log(response.statusCode); | |
pool.release(client); | |
}); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment