1. Create a server.
~> vim web-server.js
var http = require('http');
var s = createServer(function(req,res) {
res.writeHead("hello\n");
setTimeout(function() {
res.end("world");
}, 2000);
});
s.listen(8000);
2. Run the server
~> node web-server.js
3. On another terminal make a request using curl:
~> curl http://localhost:8000/
hello
world
4. The hello and world have a gap of 2 seconds.
5. Run apache bench
ab -n 100 -c 100 http://localhost:8000/
All test happen in 2.0xx seconds.
~> vim web-server.js
var http = require('http');
var s = createServer(function(req,res) {
res.writeHead("hello\n");
setTimeout(function() {
res.end("world");
}, 2000);
});
s.listen(8000);
2. Run the server
~> node web-server.js
3. On another terminal make a request using curl:
~> curl http://localhost:8000/
hello
world
4. The hello and world have a gap of 2 seconds.
5. Run apache bench
ab -n 100 -c 100 http://localhost:8000/
All test happen in 2.0xx seconds.
No comments:
Post a Comment