Tomcat Load Balancing Sample Worker.Properties File using Status Worker

If you want to load balance between 2 ore more servers in ColdFusion here is an example worker.properties file that will set it up.  You would edit for your local or remote servers.  This feature is part of Tomcat and can be used for Enterprise of Standard.  No need to setup anything in the CF Admin.

You can use this in production, or use it to emulate session failover while load testing.

The file also includes the definition for a status worker, you will need to uncomment to be able to run it.  Make sure to secure that path with IP or some other means before placing the status worker on any public site.

In a default install you will find the workers.properties and uriworkermap.properties file in your c:ColdFusion2016configwsconfig1 directory.  Or some other number that correlates to the connector you wish to use.

Also make sure the these settings match what is in your server.xml.

worker.cfusiontest.connection_pool_size=500
worker.cfusiontest.connection_pool_timeout=60

<Connector protocol=”AJP/1.3″ address=”127.0.0.1″ port=”8021″ redirectPort=”8445″ maxThreads=”500″ connectionTimeout=”60000″ connectionPoolTimeout=”60″ tomcatAuthentication=”false”/>

You might need to add an address the the above as well.

Also make sure the jvmRoute are match in the servers.xml.

All the mappings need to be mapped to the load balancer worker.  An example file is below as well.  I’d suggest to remove any unused mappings, as the lockdown guide suggests.

<Engine defaultHost=”localhost” name=”Catalina” jvmRoute=”cfusiontest”>

# Tomcat Load Balancing – Worker.properties File
# The uriworkermap file must send matched mappings to cfusion_balancer first
# Replace this file for each of the workers.properties on each server with distinct connector
# Restart IIS website to have the Tomcat Connector reload these settings
# No need to restart the IIS service
# For troubleshooting change the log level in the isapi_redirect.properties to debug (from info)
# Location of log file is also defined in the isapi_redirect.properties
#***************************
# Define Load Balancer
#***************************
worker.list=cfusion_balancer,status
worker.cfusion_balancer.type=lb
# Maintain LB worker aggregate counts in seconds (default:60)
worker.maintain=60
# Define your servers that will be balanced
worker.cfusion_balancer.balance_workers=cfusiontest,cfusiontest1
# Must turn on J2EE in CF Admin to get sticky sessions to work
worker.cfusion_balancer.sticky_session=false
# See https://tomcat.apache.org/connectors-doc/reference/workers.html to understand the all method
#R = Request method, B = Busyness, S = Session
worker.cfusion_balancer.method=R
worker.cfusion_balancer.retries=10
worker.cfusion_balancer.retry_interval=200
# Relative weight lbfactor for each member
# Higher Factors equals more requests and is proprotional
#***************************
# Local Servers
# Needs to match the jvmroute in the */runtime/conf/server.xml file
# Routes must be unique across all balance_workers
#***************************
worker.cfusiontest.type=ajp13
worker.cfusiontest.host=127.0.0.1
worker.cfusiontest.port=8021
worker.cfusiontest.max_reuse_connections=250
worker.cfusiontest.connection_pool_size=500
worker.cfusiontest.connection_pool_timeout=60
worker.cfusiontest.lbfactor=1
worker.cfusiontest.route=cfusiontest
#***************************
# Remote Servers
# Connector needs to be listening on hostport
# Connector may need address element to work
#***************************
worker.cfusiontest1.type=ajp13
worker.cfusiontest1.host=127.0.0.1
worker.cfusiontest1.port=8014
worker.cfusiontest1.max_reuse_connections=250
worker.cfusiontest1.connection_pool_size=500
worker.cfusiontest1.connection_pool_timeout=60
worker.cfusiontest1.lbfactor=1
worker.cfusiontest1.route=cfusiontest1

#Uncomment below to enable Tomcat Connector administrator
#worker.status.type=status
# Recommend to always use Read Only, simply make changes in this file
# Any changes that are made with status worker or only temporary anyway
#worker.status.read_only=false
#worker.status.mount=/private/admin/0987654321/jk

Sample URIWorkerMap.properties File

/cfformgateway/* = cfusion_balancer
/CFFormGateway/* = cfusion_balancer
/flex2gateway/* = cfusion_balancer
/flex2gateway = cfusion_balancer
/cffileservlet/* = cfusion_balancer
/CFFileServlet/* = cfusion_balancer
/cfform-internal/* = cfusion_balancer
/flashservices/gateway/* = cfusion_balancer
/flex-internal/* = cfusion_balancer
/rest/* = cfusion_balancer
/api/* = cfusion_balancer
/*.mxml = cfusion_balancer
/*.as = cfusion_balancer
/*.cfm = cfusion_balancer
/*.CFM = cfusion_balancer
/*.Cfm = cfusion_balancer
/*.cfm/* = cfusion_balancer
/*.CFM/* = cfusion_balancer
/*.Cfm/* = cfusion_balancer
/*.swc = cfusion_balancer
/*.cfml = cfusion_balancer
/*.CFML = cfusion_balancer
/*.Cfml = cfusion_balancer
/*.cfml/* = cfusion_balancer
/*.CFML/* = cfusion_balancer
/*.Cfml/* = cfusion_balancer
/*.cfc = cfusion_balancer
/*.CFC = cfusion_balancer
/*.Cfc = cfusion_balancer
/*.cfc/* = cfusion_balancer
/*.CFC/* = cfusion_balancer
/*.Cfc/* = cfusion_balancer
/*.cfr = cfusion_balancer
/*.CFR = cfusion_balancer
/*.Cfr = cfusion_balancer
/*.cfswf = cfusion_balancer
/*.CFSWF = cfusion_balancer
/*.Cfswf = cfusion_balancer
/*.sws = cfusion_balancer
/*.jsp = cfusion_balancer
/*.hbmxml = cfusion_balancer
!/CFIDE/* = cfusion_balancer

 

Leave a reply

Your email address will not be published. Required fields are marked *

By submitting this form, you accept the Mollom privacy policy.

Related