Clustering

Last modified by Ludovic Dubost on 2023/11/08

XWiki provides an easy way to setup clustered instances of XWiki based on network events distribution.

Features

  • events synchronization between XWiki instances
  • multiple clustering channels
  • possibility to start/stop the clustering channel at runtime

Setup

Use a remote Solr instance

XWiki stores a lot of information in Solr cores (e.g. Events, Indexed content), so like with the database you will need to make sure that all cluster members use the same Solr instance remotely instead of each having its own embedded instance.

Enable event distribution

To enable event distribution in an XWiki instance go to xwiki.properties file and set the property observation.remote.enabled to true.

Setup communication channels

You will need a configuration file for each different cluster group you want to setup. Generally there is only one for a simple cluster.

For this you can either:

  • use one of the files provided by jgroups ("tcp", "udp", etc. it's generally enough for most use cases and certainly a lot simpler) which can be customized through system properties
  • create your own configuration file

Create your own configuration file

For this go to the /WEB-INF/observation/remote/jgroups folder and add one xml file.

See JGroups documentation for more details on how to setup JGroups configuration files.

If you have IPv6 on your server, you are also advised to read this IPv6 article. Defining -Djava.net.preferIPv4Stack=true when launching the JVM is probably your best bet in most cases. If your really want to use IPv6 for your channels, you should probably upgrade JGroup to version 2.10.0.GA and use a JVM 6 at least.

Start communication channels

The name of the xml file matches the identifier of the channel.

To indicate which channels to start when XWiki starts list them in the property observation.remote.channels of the xwiki.properties file.

Choose network adaptor implementation to use

By default only JGroups implementation is provided, but it's possible to add more. See the Remote Observation Module for more details.

Shared filesystem

Attachments and deleted documents located on the file system (located inside the Permanent Directory) are not clustered and in order for all XWiki instance to access and display them properly in the UI, you'll need to set up a shared filesystem (e.g. NFS) and share the store/file directory. 

Note that you must not share the whole Permanent Directory or this will lead to problems (such as causing file contentions when several instances try to read/write to some of them which have locks on).

Limitations

The following limitations currently exist when you use clustering:

  • XWIKI-6235: The Scheduler feature is not cluster-aware and thus each node of XWiki runs its own scheduler and thus the same scheduler jobs will execute on all nodes. The workaround is to disable the Scheduler plugin on all nodes except on one (i.e remove com.xpn.xwiki.plugin.scheduler.SchedulerPlugin from the xwiki.plugins configuration value in xwiki.cfg). Note that this creates a SPOF and if the node containing the active Scheduler is down, the scheduled jobs won't execute.
  • XWIKI-14722 & XWIKI-1516: Attachments and deleted documents located on the file system (located inside the Permanent Directory) are currently not clustered. See above on setting up a shared filesystem to work around this.
  • XWIKI-11441 If a node is down and Events happen, these Events won't be propagated to the node when it comes back up. For example, imagine you install an Extension on a node of the cluster while another node is down. When that node is restarted, the Extension won't be installed on it.
  • XWIKI-15113: Some potential performance issues when saving large documents, as the Annotation updates (updates events and updates the annotations that are impacted by a document content change, to update the selection and context to match the new document content) will run on all nodes in the cluster instead of just once.
  • WEBSOCKET-7: Realtime editing currently doesn't work on a cluster. Each node will create a different realtime session, and the collaboration will be with the users that end up on the same cluster node.

Performances

More

See the Remote Observation Module for more details of the event distribution features and extension capabilities.

Follow the test clustering tutorial for a complete tutorial on how to setup a simple cluster between two instances of XWiki on the same server.

Get Connected