bithavoc / express-winston

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

Fix memory usage under heavy load in expressWinston.logger #164

Closed Kmaschta closed 6 years ago

Kmaschta commented 6 years ago

Create a lodash template for each request requires a lot of memory for nothing. I just moved the template allocation in the factory instead of the closure.

The following measurement shows that while running, this save a lot of memory.

Measurement

Say you have the following application: https://gist.github.com/Kmaschta/e3d0937334ac9fcccbbaf5c20b63627a

Install and run the server:

yarn install
node --inspect index.js

And send it a huge number of requests:

siege -r 1000 -c 100 http://localhost:3000

Results (before)

Transactions:             100000 hits
Availability:             100.00 %
Elapsed time:             277.24 secs
Data transferred:          13.26 MB
Response time:              0.01 secs
Transaction rate:         360.70 trans/sec
Throughput:             0.05 MB/sec
Concurrency:                5.35
Successful transactions:           0
Failed transactions:               0
Longest transaction:            2.89
Shortest transaction:           0.00

At the end image

While running image

Results (after)

Transactions:             100000 hits
Availability:             100.00 %
Elapsed time:             270.16 secs
Data transferred:          13.26 MB
Response time:              0.01 secs
Transaction rate:         370.15 trans/sec
Throughput:             0.05 MB/sec
Concurrency:                3.25
Successful transactions:           0
Failed transactions:               0
Longest transaction:            1.22
Shortest transaction:           0.00

At the end image

While running image

bithavoc commented 6 years ago

thanks 😍

bithavoc commented 6 years ago

Fixed in v2.5.0