Skip to content

Instantly share code, notes, and snippets.

@frrist
Last active August 29, 2015 14:22
Show Gist options
  • Save frrist/e996512cfca32735e5b4 to your computer and use it in GitHub Desktop.
Save frrist/e996512cfca32735e5b4 to your computer and use it in GitHub Desktop.
node --version
v0.12.2
Node code:
// Load the http module to create an http server.
var http = require('http');
// Configure our HTTP server to respond with Hello World to all requests.
var server = http.createServer(myConnect);
function myConnect(request, response) {
response.writeHead(200, {"Content-Type": "text/plain"});
response.end("Hello World\n");
}
// Listen on port 8000, IP defaults to 127.0.0.1
server.listen(8000);
// Put a friendly message on the terminal
console.log("Server running at http://127.0.0.1:8000/");
Tets Code (Apache Bench):
ab -n 10000 -c 20 http://127.0.0.1:8000/
Requests per second: 5478.13 [#/sec] (mean)
ab -n 20000 -c 20 http://127.0.0.1:8000/
Benchmarking 127.0.0.1 (be patient)
Completed 2000 requests
Completed 4000 requests
Completed 6000 requests
Completed 8000 requests
Completed 10000 requests
Completed 12000 requests
Completed 14000 requests
Completed 16000 requests
apr_socket_recv: Operation timed out (60)
Total of 16377 requests completed
I’m running this code on a 13” Macbook Pro with a 3 Ghz i7 processor and 16GB of RAM.
Node manages to spike (30% utilization) one of my CPUs for a split second and that’s it.
While 10k requests are handled at around 5000 TPS going to 20k requests often causes the test to fail with a timeout.
Furthermore, running the 10k requests over and over causes that test to stall midway as well, but it eventually completes.
Although, the result is around 300 TPS, instead of 5000 TPS. My guess is that one of the reasons for the stall is garbage collection. But maybe it’s something else?
It seems that I should be able to get much higher throughput numbers.
At a minimum, I would like to busy out one of my cores during the test.
But I don’t see any of my cores spike to 100%, and yet Node gets stuck or fails to complete the test for some reason.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment