File Synchronization in Cluster

File Synchronization Between Application Servers

The File Synchronization add-on keeps user-uploaded files and other selected application data consistent across multiple application-server nodes in one environment or across two separate environments.

This is useful for horizontally scaled applications such as WordPress, Drupal, Joomla, Liferay, and Redmine, where uploaded content may otherwise exist only on the server that originally processed the request.

File synchronisation between application servers
Changes made on one application server are synchronised to the other selected nodes.

File Synchronization Implementation

The solution is provided as a one-click add-on built around lsyncd, cron, and file-system change detection. Synchronization starts only when actual changes are detected, reducing unnecessary CPU usage compared with repeated full synchronisation calls.

Selective Folder SyncOnly the chosen part of the application-server filesystem is synchronised.
One or Two EnvironmentsSynchronise nodes inside one environment or connect application servers in separate environments.
Automatic Change DetectionUpdates are triggered only when files inside the selected directory change.
Managed StacksThe add-on works with platform-managed application servers, excluding Docker containers.

Install the Example Application

The following example uses WordPress with two NGINX-PHP application-server nodes. The same approach can be used with other supported applications and languages.

1Install WordPress

Open the Marketplace, locate WordPress, click Install, and provide the environment name, display name, and region.

Install WordPress from Marketplace
Install the WordPress package from Marketplace.
WordPress installation settings
Select the environment, display name, and region.

2Add another application-server node

Open Change environment topology, increase the number of application-server nodes in the Horizontal Scaling section, and click Apply.

Create a two-node WordPress cluster
Add a second application-server node through horizontal scaling.

Test Upload without Synchronization

3Upload a file through WordPress

Open the WordPress administration panel, sign in, and upload an image or another file to the Media Library.

WordPress login page
Sign in to the WordPress administration panel.
Upload media in WordPress
Upload a file to the WordPress Media Library.

4Compare both nodes

Open Config for the application-server layer and compare the content of webroot/ROOT/wp-content on both nodes. Without synchronization, the uploaded file appears only on the node that handled the request.

Open NGINX configuration
Open the configuration manager for the application-server layer.
Unsynchronised WordPress content
The uploaded file is present on one node but missing from the other.
Common upload paths include webroot/ROOT/wp-content for WordPress, webroot/ROOT/sites for Drupal, webroot/ROOT/images for Joomla, and webroot/home/liferay/data for Liferay.

Apply File Synchronization

5Install the add-on

Open Marketplace, locate File Synchronization, and click Install.

File Synchronization add-on
Install the File Synchronization add-on from Marketplace.

6Configure synchronization

Select One environment synchronization and provide the following values:

  • Sync path: Directory relative to the webroot, for example /ROOT/wp-content.
  • Sync delay (sec): Number of seconds to wait before synchronising changes.
  • Environment name: Target environment.
  • Nodes: Application-server layer selected automatically after choosing the environment.
Configure one-environment file synchronization
Set the synchronization path, delay, environment, and application-server layer.

Click Install. After installation completes, the uploaded files become available on all selected nodes.

File Synchronization successfully installed
The add-on confirms successful installation.
Synchronized files on both nodes
The uploaded content is now present on both application-server nodes.
When additional application-server nodes are added later, the add-on automatically includes them in synchronization without requiring manual reconfiguration.

Synchronize Two Environments

To synchronize application servers across two different environments, install the add-on in both environments and choose Two environments synchronization.

  • 2nd environment IP: Internal IP when both environments are on the same platform and hardware region; otherwise use an external IP.
  • Password: Optional synchronization password. Use the same value on both sides.
Two-environment file synchronization
Provide the remote environment IP and matching password when synchronizing two environments.

Mount-Point Exceptions

When the synchronized directory contains mount points, add those paths to the exceptions in:

<sync_path>/lsyncd/etc/lsyncd.conf

Then restart synchronization by terminating the running rsync and lsyncd processes on each node:

for pid in $(ps aux | grep 'rsync\|lsyncd' | awk '!/grep/{print $2}'); do kill -9 $pid; done
Important: Exclude mounted directories before restarting synchronization to prevent unwanted copying or recursion through mounted storage.

Check Synchronization Logs

Synchronization logs are stored in the following directory on the application server:

webroot/lsyncd/var/log
File Synchronization log directory
Open the lsyncd log directory through the configuration manager.

The most useful files are lsyncd.log and lsyncd.status, which show synchronization events and the current state.

lsyncd status file
Review watched directories, delay settings, and current synchronization status.

What’s next?