Scaling SymmetricDS For Many Clients

SymmetricDS was originally designed to support a use case with numerous client nodes spread out geographically in order to replicate to a centralized server.  The out of the box properties and configuration are optimized to support many other use cases and may not be sufficient when you need more than a couple dozen client nodes.   Check out some of the helpful hints below to assist in a successful synchronization rollout to numerous clients.

Installation

In order to rollout a large number of client nodes there is usually a process to help automate the installation and setup. During the installation of SymmetricDS there is an option to generate an auto-install.xml file that can be provided to help automate future installations. Essentially the decisions made during the initial installation are captured in this file so they can be repeated.  Here is additional information on how to run this install xml file.

Configuration

There are several configuration parameters that might assist in rolling out a lot of client nodes.   Below are some of the parameters to consider.

auto.registration=true

This allows a node to automatically be allowed to register without any human interaction.   This might be turned back off for security purposes once the rollout is complete.

auto.reload=true

This will cause an initial load to be sent to the client once it has successfully registered.

initial.load.create.first=true

This would work with the above parameter to also create the tables in the client database

On the server configuration it might be beneficial to set the reload channel’s data loader type to “bulk”.  This will perform bulk loading of data to the client during the initial load if it is supported for the clients database (ex.  MySQL, Oracle, MSSQL, Postgres, Snowflake, Redshift).

Connections, Worker Threads, and Queues

There are 3 areas that can be adjusted to account for more clients access the servers and servicing them in parallel.

Database Pool Connections – The database pool size should be at least double the size of the worker threads.  This allows for both push and pulls to occur in parallel and access the database without waiting.

The following parameter controls the number of active connections in the pool and defaults to 40 (20 client nodes concurrently able to pull and push at any given time).

db.pool.max.active=40

Worker Threads – The number of clients that can concurrently connect to push/pull.

The following parameter controls the number workers allowed concurrently and defaults to 20).   NOTE: the database pool size mentioned above should be double this value.

http.concurrent.workers.max=20

Channel Queues – By default channels will push or pull in series.   Using different channel queues allows the channels to then push or pull in parallel.   A “default” queue is provided for all channels initially.   Channel queue names are provided by the user and not restricted the system.   Each unique value for a channel queue will cause it to run in parallel.  Creating more channel queues though will require more workers as mentioned above.    So if you had 4 channel queues defined and 20 worker threads the system would only be able to service 5 clients concurrently if all channel queues had changes to sync.

Personalization

Each SymmetricDS node is defined initially by an engine properties file.   This property file will generally be the same for all the client nodes with a few differences (personalizations).

Some users will use some other tools (chef or puppet) or custom scripts to change change some variables in a property file template that will result in the personalized file for each store.  Below is an example of what a template might look like before variables are replaced.

There are 4 variables used in the below example:

  • ${CLIENT_ID}
  • ${CLIENT_HOST}
  • ${CENTRAL_HOST}
  • ${CLIENT_ENCODED_PASS}
external.id=${CLIENT_ID}
engine.name=client-${CLIENT_ID}
sync.url=http://${CLIENT_HOST}:31415/sync/client-${CLIENT_ID}
group.id=client
db.url=jdbc:h2:file:clientdb;LOCK_TIMEOUT=60000;WRITE_DELAY=0
db.driver=org.h2.Driver
db.user=symmetric
registration.url=http://${CENTRAL_HOST}:31415/sync/server
db.validation.query=select 1
db.init.sql=
db.password=enc:${CLIENT_ENCODED_PASS}
db.connection.properties=

Once this file is placed in the engines folder of SymmetricDS and restarted the node will automatically start up and install the SymmetricDS tables (SYM_*) and attempt to register with the central node.   Upon a successful registration it will receive all SymmetricDS configuration and be ready for replication.

Clustering / Load balancing

Often times the need for more than one server is required to support the load of client nodes communicating with it.   SymmetricDS supports clustering in these scenarios.   To setup clustering support the engine property files for all nodes in the cluster should look identical with the sync.url property utilizing the url provided by the load balancer.   An additional property is also required so that each engine is aware it is part of a cluster (cluster.lock.enabled=true).   The combination of adding more clustered servers along with configuring the database pool and worker set properly will allow your clients the maximum benefit of real time data synchronization.

Read more about Clustering in the online documentation.