Hazelcast is used by default in P2P mode. As the project is stateful, a load balancer needs to use sticky sessions to maintain users’ state. The picture below outlines the deployment structure, but with Hazelcast there is no need for ActiveMQ.
EhCache and JSM
This picture shows how to scale out the project with EhCache and JSM. As the project is stateful, a load balancer needs to use sticky sessions to maintain users’ state.
Master and Slave
Each Tomcat server to which the project’s WAR is deployed must have one of the following statuses:
There can be only one master. The master runs tasks which operate on shared resources such as cleaning temporary files, re-submitting objects to Solr, database maintenance etc.
There may be many slaves. A slave participates in master election and may become the master itself. If there is no master then slaves vote for a random server and the server with most of the votes is promoted to the master.
This status is the same as slave. During an election process it can vote but cannot become the master. Idle status is set manually by the administrator.
A server is marked as dead if it stops responding.
Each server has a heartbeat record in the database, which it periodically updates to show that it is alive. More than that, each server keeps track of all the other servers, if one of them stops updating its heartbeat record then it will be marked as dead. Once a dead server comes back online, it will become a slave.
Heartbeat record contains server’s IP address, to prevent collision it is recommended to overwrite this in the properties file.
The bottom part of the picture shows resources the project depends upon. The database cluster, the one-for-all file system (which can reside on NAS) and the Solr cluster. It is recommended to provide high availability of such resources.
- Install and run ActiveMQ.
Uncomment "Replicated via JSM" code parts in the "ehcache.xml" file and change "thehost:61616" to the host and port you are running ActiveMQ on.
Add "scaled=1" to the "SystemParams" database setting, which will enable heartbeats and master/slaves.
Verify that the project settings in the database point to proper file system path and Solr URL, those resources must be available to all the servers you deploy the project on.
Configure the load balancer to use sticky sessions.
Deploy the project.