lang/node

Node.js helloWorld

C/H 2018. 6. 10. 08:30

Node.js

var http = require('http');
http.createServer(function (req, res) {
  res.writeHead(200, {'Content-Type': 'text/plain'});
  res.write('Hello World!');
  res.end();
}).listen(1337);
node app.js

# other terminal
ab -n 10000 -c 10 -k http://127.0.0.1:1337/
.....
Concurrency Level:      10
Time taken for tests:   0.766 seconds
Complete requests:      10000
Failed requests:        0
Keep-Alive requests:    0
Total transferred:      1130000 bytes
HTML transferred:       120000 bytes
Requests per second:    13053.45 [#/sec] (mean)
Time per request:       0.766 [ms] (mean)
Time per request:       0.077 [ms] (mean, across all concurrent requests)
Transfer rate:          1440.47 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.0      0       1
Processing:     0    1   0.4      1       6
Waiting:        0    1   0.4      1       6
Total:          0    1   0.4      1       6

Percentage of the requests served within a certain time (ms)
  50%      1
  66%      1
  75%      1
  80%      1
  90%      1
  95%      2
  98%      2
  99%      2
 100%      6 (longest request)

Node.js Express

var express = require('express');
var app = express();

app.get('/', function (req, res) {
  res.send('Hello World!');
});

app.listen(1337, function () {
  console.log('Example app listening on port 1337!');
});
node app2.js

# other terminal
ab -n 10000 -c 10 -k http://127.0.0.1:1337/
.....
Concurrency Level:      10
Time taken for tests:   0.879 seconds
Complete requests:      10000
Failed requests:        0
Keep-Alive requests:    10000
Total transferred:      2160000 bytes
HTML transferred:       120000 bytes
Requests per second:    11373.76 [#/sec] (mean)
Time per request:       0.879 [ms] (mean)
Time per request:       0.088 [ms] (mean, across all concurrent requests)
Transfer rate:          2399.15 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.0      0       1
Processing:     0    1   0.6      1       7
Waiting:        0    1   0.6      1       7
Total:          0    1   0.6      1       7

Percentage of the requests served within a certain time (ms)
  50%      1
  66%      1
  75%      1
  80%      1
  90%      1
  95%      2
  98%      2
  99%      3
 100%      7 (longest request)


반응형

'lang > node' 카테고리의 다른 글

Full Stack Framework Sails.js For Node.js  (0) 2019.02.14
node.js json-server  (0) 2018.06.13
node.js Common System Errors  (0) 2018.02.23
express-socket.io-session  (0) 2018.02.13
node.js 64bit int buffer  (0) 2018.01.25