Troubleshooting performance of Sitecore JSS in Azure App Services

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:
https://sitecore.stackexchange.com/questions/16257/profiling-sitecore-9-1-jss-server-side-rendering-node-server

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.

Findings

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.

Solution

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 😉

Troubleshooting performance of Sitecore JSS in Azure App Services

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s