I am using Node 10.10.0 latest version and below is the small peice of code that I am trying to execute.
var fs = require('fs');
const express = require('express');
const request = require('request');
const app = express();
async function fun1(req, resp){
let response = await request.get('http://google.com');
if (response.err) { console.log('error');}
else { resp.send('fetched response'); };
}
app.get('/', (req, res) => {
fun1(req, res);
});
app.listen(3000, () => {
console.log('Example app listening on port 3000!');
});
I am also using clinic doctor to check performance bottleneck for above code.
I am running command as below;
clinic doctor --on-port 'autocannon -c100 localhost:3000' -- node index.js
I get below console output on executing above command.
Example app listening on port 3000!
Running 10s test @ http://localhost:3000
100 connections
Stat Avg Stdev Max
Latency (ms) 94.72 75.87 1077.87
Req/Sec 827 257.35 1248
Bytes/Sec 180 kB 55.7 kB 270 kB
9k requests in 11s, 1.96 MB read
9 errors (0 timeouts)
Analysing data
Generated HTML file is 3884.clinic-doctor.html
You can use this command to upload it:
clinic upload 3884.clinic-doctor
and also I get a nice UI generated and it opens automatically as below,
QUESTION Why is my application when tested for performance bottleneck goes on creating Active Handles as seen in the 4th chart in the image? DO I need to close anything? Did I forget anything?