From befb1926513d850d357034c44fb90c7576b1481c Mon Sep 17 00:00:00 2001 From: wiz Date: Mon, 15 Feb 2021 00:25:29 +0900 Subject: [PATCH] Reduce backend heap size setting to 2G since cache memory usage was optimized (#345) On powerful servers, nodejs automatically sets the limit at 4GB ``` % node -e 'console.log(`node heap limit = ${require("v8").getHeapStatistics().heap_size_limit / (1024 * 1024)} Mb`)' node heap limit = 4144 Mb ``` On a Raspberry Pi with 8GB RAM, nodejs automatically sets the limit at 1GB ``` % node -e 'console.log(`node heap limit = ${require("v8").getHeapStatistics().heap_size_limit / (1024 * 1024)} Mb`)' node heap limit = 1048 Mb ``` On a Raspberry Pi with 4GB RAM, nodejs automatically sets the limit at 740MB ``` % node -e 'console.log(`node heap limit = ${require("v8").getHeapStatistics().heap_size_limit / (1024 * 1024)} Mb`)' node heap limit = 739.4694900512695 Mb ``` After testing with manually setting the limit to 768MB, mempool starts up fine, but crashes when saving the cache when the mempool is quite large (over 400MB with custom bitcoin.conf setting). So it's probably safe to reduce the 4GB limit setting to 2GB for all devices and and just use the automatically set values, now that the backend's disk cache memory usage was recently optimized. However, a new npm script for `npm run start-production` will be added so we can keep our production mempool.space servers running with a very large bitcoin.conf mempool --- backend/package.json | 3 ++- production/mempool-start-all | 5 +---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/backend/package.json b/backend/package.json index ae5f3dd81..a8add53e8 100644 --- a/backend/package.json +++ b/backend/package.json @@ -23,7 +23,8 @@ "ng": "./node_modules/@angular/cli/bin/ng", "tsc": "./node_modules/typescript/bin/tsc", "build": "npm run tsc", - "start": "node --max-old-space-size=4096 dist/index.js", + "start": "node --max-old-space-size=2048 dist/index.js", + "start-production": "node --max-old-space-size=4096 dist/index.js", "test": "echo \"Error: no test specified\" && exit 1" }, "dependencies": { diff --git a/production/mempool-start-all b/production/mempool-start-all index 338197b5a..3c7a445db 100755 --- a/production/mempool-start-all +++ b/production/mempool-start-all @@ -4,8 +4,5 @@ source "$NVM_DIR/nvm.sh" for site in mainnet liquid testnet bisq do cd "${HOME}/${site}/backend/" - screen -dmS "${site}" sh -c 'while true;do npm run start;sleep 1;done' + screen -dmS "${site}" sh -c 'while true;do npm run start-production;sleep 1;done' done - -#cd "${HOME}/webhook/" -#screen -dmS webhook ./start