Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Add notes on enabling PM2 cluster mode via JSON

...

If you are using PM2 to run the User Interface, you may want to start it using PM2's "Cluster Mode".  This allows Node.js applications to be scaled across multiple CPUs by using the Node.js cluster module.  See the PM2 Cluster Mode documentation at https://pm2.keymetrics.io/docs/usage/cluster-mode/

There are two ways to enable cluster mode. Choose one.

  1. First, is by adding the "exec_mode" and "instances" settings to your JSON configuration as follows.  The "exec_mode" setting enables cluster mode, while the "instances" setting allows you to customize how many CPUs are available to PM2 ("max" = all CPUs, but you also can specify a number.)

    Code Block
    languagejs
    titledspace-ui.json
    {
        "apps": [
            {
               "name": "dspace-ui",
               "cwd": "/full/path/to/dspace-ui-deploy",
               "script": "dist/server/main.js",
               "instances": "max",
               "exec_mode": "cluster",
               "env": {
                  "NODE_ENV": "production"
               }
            }
        ]
    }


  2. Alternatively, you can pass in the "-i" flag with either "max" or a number to tell PM2 to run in cluster mode across that many CPUs:

    Code Block
    # Start the "dspace-ui" app & cluster it across all available CPUs
    pm2 start dspace-ui.json -i max


Give Node.js more memory

On machines with >2GB of memory available, Node will only use a maximum of 2GB of memory by default (see https://github.com/nodejs/node/issues/28202).  This 2GB of memory should be enough to build & run the User Interface, but it's possible that highly active sites may require 4GB or more.

...