Closed Kmaschta closed 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.
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
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
While running
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
thanks 😍
Fixed in v2.5.0
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:
And send it a huge number of requests:
Results (before)
At the end![image](https://user-images.githubusercontent.com/1819833/36097600-db3cde78-0ffb-11e8-8e9e-06edea606191.png)
While running![image](https://user-images.githubusercontent.com/1819833/36097647-1d8527c2-0ffc-11e8-9b72-452e179b1b4d.png)
Results (after)
At the end![image](https://user-images.githubusercontent.com/1819833/36097926-38b965de-0ffd-11e8-9501-4360b4039018.png)
While running![image](https://user-images.githubusercontent.com/1819833/36097751-84313cc2-0ffc-11e8-9e1c-b940f781bbdc.png)