bithavoc / express-winston

express.js middleware for winstonjs
https://www.npmjs.com/package/express-winston
MIT License
797 stars 186 forks source link

Performance issue #250

Open kenhuang opened 4 years ago

kenhuang commented 4 years ago

Thanks for the library, during our testing with these few lines of changes, we see performance increase (6298.7 req/s vs 3088.48 req/s ) when using the request logger. Please point out any issues, happy to create PR for this.

before:

autocannon -c 100 -d 40 -p 10 http://localhost:9876/metrics
Running 40s test @ http://localhost:9876/metrics
100 connections with 10 pipelining factor

┌─────────┬──────┬──────┬────────┬────────┬──────────┬──────────┬────────────┐
│ Stat    │ 2.5% │ 50%  │ 97.5%  │ 99%    │ Avg      │ Stdev    │ Max        │
├─────────┼──────┼──────┼────────┼────────┼──────────┼──────────┼────────────┤
│ Latency │ 0 ms │ 0 ms │ 321 ms │ 331 ms │ 32.16 ms │ 96.53 ms │ 1209.07 ms │
└─────────┴──────┴──────┴────────┴────────┴──────────┴──────────┴────────────┘
┌───────────┬─────────┬─────────┬─────────┬───────┬─────────┬─────────┬─────────┐
│ Stat      │ 1%      │ 2.5%    │ 50%     │ 97.5% │ Avg     │ Stdev   │ Min     │
├───────────┼─────────┼─────────┼─────────┼───────┼─────────┼─────────┼─────────┤
│ Req/Sec   │ 1912    │ 1912    │ 3133    │ 3207  │ 3088.48 │ 205.89  │ 1912    │
├───────────┼─────────┼─────────┼─────────┼───────┼─────────┼─────────┼─────────┤
│ Bytes/Sec │ 13.4 MB │ 13.4 MB │ 22.5 MB │ 23 MB │ 22.1 MB │ 1.53 MB │ 13.4 MB │
└───────────┴─────────┴─────────┴─────────┴───────┴─────────┴─────────┴─────────┘

Req/Bytes counts sampled once per second.

124k requests in 40.06s, 885 MB read

after:

autocannon -c 100 -d 40 -p 10 http://localhost:9876/metrics
Running 40s test @ http://localhost:9876/metrics
100 connections with 10 pipelining factor

┌─────────┬──────┬──────┬────────┬────────┬──────────┬──────────┬───────────┐
│ Stat    │ 2.5% │ 50%  │ 97.5%  │ 99%    │ Avg      │ Stdev    │ Max       │
├─────────┼──────┼──────┼────────┼────────┼──────────┼──────────┼───────────┤
│ Latency │ 0 ms │ 0 ms │ 158 ms │ 168 ms │ 15.77 ms │ 47.16 ms │ 430.57 ms │
└─────────┴──────┴──────┴────────┴────────┴──────────┴──────────┴───────────┘
┌───────────┬─────────┬─────────┬─────────┬─────────┬─────────┬─────────┬─────────┐
│ Stat      │ 1%      │ 2.5%    │ 50%     │ 97.5%   │ Avg     │ Stdev   │ Min     │
├───────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┤
│ Req/Sec   │ 4955    │ 4955    │ 6311    │ 6599    │ 6298.7  │ 241.14  │ 4955    │
├───────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┤
│ Bytes/Sec │ 35.6 MB │ 35.6 MB │ 45.3 MB │ 47.3 MB │ 45.2 MB │ 1.72 MB │ 35.6 MB │
└───────────┴─────────┴─────────┴─────────┴─────────┴─────────┴─────────┴─────────┘

Req/Bytes counts sampled once per second.

252k requests in 40.06s, 1.81 GB read