Cluster configuration (cluster.json)
This page describes the structure, attributes, and interaction of the configuration in cluster.json for operating the webPDF Server in a clustered environment. Alternatives using environment variables are also explained.
In SINGLE mode, the cluster.json file is not required.
Purpose
With cluster.json, you control whether a server node runs as a standalone instance (SINGLE) or within a cluster (CLUSTER), which role the node assumes (COORDINATOR/MEMBER), under which cluster name it operates (name), how it is identified (nodeName), how cluster communication is secured (secretKey), how strictly join errors are handled during startup (stopOnError), and how long to wait at startup (connectTimeout).
- The cluster name (
name, sometimes referred to asclusterName) must be a unique identifier for the cluster. - The node name (
nodeName) must be a unique identifier for each node.
Structure
The cluster.json is a single JSON object with the following attributes:
mode:stringrole:stringname:stringnodeName:stringsecretKey:stringstopOnError:booleanconnectTimeout:number(milliseconds)namespace:object(optional)configuration:object(optional)
Attributes
mode
- Meaning: Switches between standalone and cluster mode.
- Valid values:
SINGLE– single node (default)CLUSTER– clustered operation
- Behavior:
SINGLE: Clustering is disabled;cluster.jsonmay be omitted.CLUSTER: Clustering is enabled; further cluster attributes apply (see below).
role
- Meaning: The node’s function within the cluster.
- Valid values:
COORDINATOR– initializes the cluster and distributes configuration.MEMBER– joins an existing cluster (default).
- Applies only when
mode=CLUSTER.
name
- Meaning: Logical name of the cluster.
- Requirements:
- Must be a unique identifier across all clusters that might be reachable in your environment(s).
- Behavior:
COORDINATOR: Creates/initializes a cluster under this name.MEMBER: Attempts to join the cluster with this name.
- Default:
""(set explicitly in cluster mode). - Recommendations:
- Use a stable, descriptive, and unique value (for example, a namespaced name like
prod/eu-west/webpdfor a UUID if in doubt).
- Use a stable, descriptive, and unique value (for example, a namespaced name like
nodeName
- Meaning: Display name/identifier of this node.
- Requirements:
- Must be a unique identifier per node within the cluster.
- Behavior: If
nodeNameis empty or not set, the host name is used. If no host name is available at runtime, a random UUID may be generated. - Default:
""(host name will be used). - Recommendations:
- Use clear, unique names for monitoring and operations, e.g.,
coordinator-1,member-1.
- Use clear, unique names for monitoring and operations, e.g.,
secretKey
- Meaning: Shared key for encrypting intra-cluster communication.
- Requirements:
- 64-character hexadecimal string (256-bit).
- All nodes in the same cluster must use exactly the same key.
- Security: Keep it secret; do not commit it to version control.
→ Complete Secret Key Documentation - Detailed guide on generation, distribution, security, and rotation
stopOnError
- Meaning: How to handle errors during cluster join/startup.
- Behavior:
true(default): Node continues to start even if such an error occurs.false: Startup is aborted in case of such errors.
- Trade-off: Availability (
true) vs. strictness/consistency (false).
connectTimeout
- Meaning: Wait time in milliseconds while joining/starting in cluster mode (e.g., waiting for the
COORDINATOR). - Type:
number(milliseconds) - Default:
60000 - Recommendation: Increase in slower environments.
namespace
- Meaning: Namespace settings used to create prefixes (e.g., Redis hash keys) or default names (e.g., S3 buckets) for this cluster.
- Type:
object(optional) - Structure:
org:string– Optional organization/vendor identifier (default:"webpdf")app:string– Application identifier (required, default:"webpdf")env:string– Optional environment name (e.g.,"prod","dev")region:string– Optional region identifier (e.g.,"eu1")cluster:string– Optional cluster discriminator for blue/green or canary deployments (e.g.,"blue")version:string– Key schema version (default:"v10.0")
- Purpose: Provides structured namespace components for building Redis/S3 prefixes and ensuring logical separation of resources across different environments, regions, and deployment strategies.
configuration
- Meaning: Configuration settings for how cluster nodes receive their configuration.
- Type:
object(optional) - Structure:
source:string– Defines where nodes receive configuration fromCOORDINATOR(default) – Configuration is provided by the coordinator to all nodesNODE– Each node uses its local configuration settings
- Behavior:
COORDINATOR: All member nodes receive configuration from the coordinator node, ensuring consistency across the cluster.NODE: Each node uses its own local configuration, allowing for node-specific settings.
Ensure both name (cluster identifier) and nodeName (node identifier) are unique in their respective scopes. Duplicate values can lead to unintended joins or operational ambiguity.
Examples
- SINGLE (no cluster)
- CLUSTER · COORDINATOR
- CLUSTER · MEMBER
- CLUSTER · COORDINATOR (with namespace & configuration)
{
"mode": "SINGLE"
}
{
"mode": "CLUSTER",
"role": "COORDINATOR",
"name": "webpdf-prod-cluster",
"nodeName": "coordinator-1",
"secretKey": "4f0a2c8efb1a0f9c79c4b0f5a81e6d5b4a7c8d9e2f0a1b2c3d4e5f60718293ab",
"stopOnError": true,
"connectTimeout": 60000
}
{
"mode": "CLUSTER",
"role": "MEMBER",
"name": "webpdf-prod-cluster",
"nodeName": "member-1",
"secretKey": "4f0a2c8efb1a0f9c79c4b0f5a81e6d5b4a7c8d9e2f0a1b2c3d4e5f60718293ab",
"stopOnError": true,
"connectTimeout": 60000
}
{
"mode": "CLUSTER",
"role": "COORDINATOR",
"name": "webpdf-prod-cluster",
"nodeName": "coordinator-1",
"secretKey": "4f0a2c8efb1a0f9c79c4b0f5a81e6d5b4a7c8d9e2f0a1b2c3d4e5f60718293ab",
"stopOnError": true,
"connectTimeout": 60000,
"namespace": {
"org": "acme",
"app": "webpdf",
"env": "prod",
"region": "eu1",
"cluster": "blue",
"version": "v10.0"
},
"configuration": {
"source": "COORDINATOR"
}
}
Generate a 256-bit key for secretKey by creating 32 random bytes and encoding them in hexadecimal (64 characters). Use openssl rand -hex 32 or see the Secret Key Guide for more methods.
Environment variables
All settings can also be provided via environment variables as an alternative to cluster.json.
- Notation: Always UPPERCASE
- Prefix:
WEBPDF_CLUSTER_SETTINGS_ - Dots in the logical prefix are replaced by underscores.
- Attribute mapping:
mode→WEBPDF_CLUSTER_SETTINGS_MODErole→WEBPDF_CLUSTER_SETTINGS_ROLEname→WEBPDF_CLUSTER_SETTINGS_NAMEnodeName→WEBPDF_CLUSTER_SETTINGS_NODE_NAMEsecretKey→WEBPDF_CLUSTER_SETTINGS_SECRET_KEYstopOnError→WEBPDF_CLUSTER_SETTINGS_STOP_ON_ERRORconnectTimeout→WEBPDF_CLUSTER_SETTINGS_CONNECT_TIMEOUT(milliseconds)namespace.org→WEBPDF_CLUSTER_SETTINGS_NAMESPACE_ORGnamespace.app→WEBPDF_CLUSTER_SETTINGS_NAMESPACE_APPnamespace.env→WEBPDF_CLUSTER_SETTINGS_NAMESPACE_ENVnamespace.region→WEBPDF_CLUSTER_SETTINGS_NAMESPACE_REGIONnamespace.cluster→WEBPDF_CLUSTER_SETTINGS_NAMESPACE_CLUSTERnamespace.version→WEBPDF_CLUSTER_SETTINGS_NAMESPACE_VERSIONconfiguration.source→WEBPDF_CLUSTER_SETTINGS_CONFIGURATION_SOURCE
If both cluster.json and environment variables are provided, environment variables usually take precedence.
Relation within the application
- Startup behavior:
mode=SINGLE: The server runs as a standalone instance;cluster.jsonis not required.mode=CLUSTER:role=COORDINATOR: The node initializes the cluster undernameand distributes configuration.role=MEMBER: The node attempts to join the cluster identified byname; wait time according toconnectTimeout.
- Uniqueness requirements:
- The cluster name (
name/clusterName) must be a unique identifier within the reachable network/domain to prevent unintended joins between distinct clusters. - The node name (
nodeName) must be unique within the cluster to ensure unambiguous identification in logs, metrics, and administration tools.
- The cluster name (
- Security:
secretKeymust be identical on all nodes to enable encrypted communication. - Robustness:
stopOnErrorcontrols whether the node continues to start despite join errors.