All Versions
- DSpace 7.x (Current Release)
- DSpace 8.x (Unreleased)
- DSpace 6.x (EOL)
- DSpace 5.x (EOL)
- More Versions...
...
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.You also may want to set the "max_memory_restart" option to avoid PM2 using too much memory. These three settings are described in more detail below. NOTE: make sure to start (or restart) your site to enable these settings (e.g. pm2 start dspace-ui.json
)
Code Block | ||||
---|---|---|---|---|
| ||||
{ "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" }, } "max_memory_restart": "500M" ] } |
Then, start (or restart) your site as normal (e.g. pm2 start dspace-ui.json
)
}
]
} |
Setting "exec_mode" to "cluster" will enable cluster mode,
Alternatively, you can use command line flags to specify the same settings described above. The "-i" flag enables cluster mode and specifies the number of instances. The "--max-memory-restart" flag limits the memory per instance.
Code Block |
---|
# Start the "dspace-ui" app. Cluster it across all available CPUs with a maximum memory of 500MB per CPU.
# This command is equivalent to the example cluster settings in the "dspace-ui.json" file above. |
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 --max-memory-restart 500M |
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.
...