In a multiple-node NexJ Model Server environment, you can configure the web server to act as a load balancing server that redirects requests to the separate nodes.
For this configuration, first ensure that the node names for each of the Model Server instances in your cluster are defined correctly. Then edit the .properties files in the mod_jk/conf
directory to define the Tomcat instance (also known as a Tomcat worker) for each Model Server instance in the cluster.
The following are examples of files used to configure a typical multiple-node Model Server deployment. Analyze your configuration and adjust these settings accordingly.
To configure the Tomcat Connector for a multiple-node Model Server deployment:
- Edit the
uriworkermap.properties
file to define the nodes for your deployment. For example:
CODE
/nexj/*=loadbalancer
Edit the workers.properties
file to configure the nodes and their properties. For example:
TEXT
# The list of nodes
#
worker.list=loadbalancer,status
# Set load-balancing behaviour
#
worker.loadbalancer.type=lb
worker.loadbalancer.balance_workers=node1,node2
worker.loadbalancer.sticky_session=1
# Set template properties
#
worker.template.type=ajp13
worker.template.lbfactor=1
worker.template.socket_timeout=0
worker.template.socket_keepalive=true
worker.template.socket_connect_timeout=5000
worker.template.retries=2
worker.template.recovery_options=7
worker.template.connection_pool_size=256
worker.template.connection_pool_timeout=300
# Set properties for node 1
#
worker.node1.reference=template
worker.node1.host=localhost
worker.node1.port=8009
worker.node1.route=node1
# Set properties for node 2
#
worker.node2.reference=template
worker.node2.host=localhost
worker.node2.port=8109
worker.node2.route=node2
# Set properties for status worker
#
worker.status.type=status
worker.status.read_only=true
The values for the worker.nodename.host and worker.nodename.port properties must correspond to your Model Server configuration. If you add or remove any workers, change the worker.loadbalancer.balance_workers property.
Node names such as "node1" or "node2" are used by default when the servers are configured through NexJ Studio. If you specify different names, use the worker.nodename.route property to map the node names and worker names correctly.
By default, the value of the worker.nodename.route property is set to the worker name. If that is the case, you do not have to include this property. In a typical production environment, only one cluster is configured for each mod_jk module, so this property is not required.
In the configuration, the following suggested values are used:worker.<nodename>.type
The value is always ajp13. Other worker types are unsupported.
worker.nodename.retries
Suggested value is 2. The maximum number of times that the node will try to establish a connection to the server after a communication error.
worker.nodename.recovery_options
Suggested value is 7. This value is a bitmask. It indicates that, when an error occurs that prevents a complete AJP request from being sent, the server will not retry the request and will close the AJP connection. This prevents automatic request and response duplication.
worker.nodename.connection_pool_size
If using Apache Tomcat connector on Linux, suggested value is 1. In all other cases, suggested value is 256. The lower of the maximum Model Server AJP listener thread count and the maximum web server thread count.
The default maximum Model Server AJP listener thread count is 200. (refer to the maxThreads
attribute for the Connector component for AJP).
To determine the maximum web server thread count: Refer to Apache or IIS configuration to find the maximum number of web requests that the server can process concurrently.
worker.nodename.connection_pool_timeout
Suggested value is 300. The number of seconds after which the idle connections in the pool are closed.
worker.nodename.socket_keepalive
Suggested value is true. Sends TCP keepalive messages to maintain the connection.
worker.nodename.socket_timeout
Suggested value is 0. Indicates that IIS should wait for the server response indefinitely.
worker.nodename.socket_connect_timeout
Suggested value 1 if using Apache Tomcat connector on Linux and 5000 in all other cases. The number of milliseconds after which the attempted connection establishment times out.
- If you are configuring an existing web server that is currently running, restart the web server after modifying the configuration files.