Some time ago we faced an issue with NodeJS slowing JSS in integrated mode significantly over time in Azure PaaS. We saw request growing from sub-second to 3-4 seconds. Here is what you need to check as you do troubleshooting of your solution.
Configurations & Checks
Pass custom parameters to Node JS in integrated mode
First of all, we tried to gather some information about NodeJS. In order to do that, we followed a recommendation by Adam, which you can find here:
This will allow you to run NodeJS in –profile mode and gather some profile information.
node --prof server.bundle.js
Process profile logs
After loading the site for some time you will need to go to Azure KUDU console, kill node processes and navigate to the location of your server bundle. Next to it you will find logs generated by the profiler.
In order to read it you’ll need to process it with the following command:
node --prof-process ./isolate-XXXXXXXX-v8.log > isolate-XXXXXXXX-v8.txt
Check the version of Node in Azure
kudu > run ‘node –version’
Important to match Azure node version and version of your prof-process
Kudu > run
node -p "process.arch" or
node -p "process" for full info about node.
Check available versions
Some of the issues might be related to older versions of node.js referenced by your application via
WEBSITE_NODE_DEFAULT_VERSION variable in App Service configuration.
To find out what versions are available got to KUDU > Runtime versions > check node.js.
After some time of trials end errors, we figured out that issue was related with nodejs process not cleaning up memory after a significant amount of working under load. We saw that the process eating up to 750MB of RAM after load tests.
We also notices that memory accumulation was significantly improved by an upgrade from nodejs v8 LST to v10 LST.
Cheap and dirty solution for us was to leverage JSS mechanism of reloading new JS bundles.
Behind the scene, JSS monitors your dist folder for updates of JS and JSON files. So we end up creating
reset.json file and updating it via Sitecore agent every hour.
As usual, follow me on twitter @true_shoorik 😉