This topic describes how to configure multiple Node.js Agent on a machine to share a single, multi-tenant Java proxy.
About Proxy Sharing
Each Node.js agent on a machine normally launches its own proxy instance, having created the control directory for its proxy based on a unique combination of application, tier, and node name for the agent. The control directory contains the configuration for the agent as well as the domain control socket, which the agent uses to start an AppDynamics node.
If running multiple Node.js agents on a single machine, you can configure them to use a shared Java proxy. A shared proxy (also called multi-tenant proxy) reduces the overhead of additional proxies.
A shared proxy is required configuration if you use an external process manager, such as PM2.
Configure a Shared Proxy
- Stop the Node.js application.
Create directories for the agent and the agent logs and for the proxy control directory. The permissions on this directory must be readable and executable by the application user that the application and writable by the proxy user. For example:
You may want to devise a technique for creating these directories automatically whenever you upgrade the Node.js agent.
Disable automatic proxy launching for each agent. In the AppDynamics require.profile() block, set proxyAutolaunchDisabled to true and set the proxyCtrlDir to the directory that you created. For example:
Ensure that each agent that reports to the multi-tenant proxy is configured with a unique node name.
- Start the shared Java proxy before you start the agents, passing the agent control directory as the proxyCommunicationDir argument to the runproxy script. See . AppDynamics recommends that you configure the proxy to start on system startup.
- Restart the Node.js application. In a few minutes, the nodes should appear in the Controller UI flow maps.
Proxy Sharing Limits
In its default configuration, a single proxy can handle up to ten agents. If you need to run more, you will likely need to adjust the maxHeapSize and maxPermSize settings in the runproxy script.
When adding agents, use debug mode and monitor the proxy.out file, which indicates whether the proxy is running out of heap. The file is visible when running in debug mode.