NiFi Registry HA

NiFi Registry supports high availability (HA) through NIFI-8843. The Registry runs as a separate cluster alongside the NiFi cluster.

Architecture overview

┌──────────────────────────────────────────┐ │ Apache ZooKeeper │ │ /nifi-registry/leaders/registry-leader │ │ /nifi-registry/members/<nodeId> │ │ /nifi-registry/cache-version/... │ └──────────────────┬───────────────────────┘ │ Curator / ZK client ┌──────────────────────────┼───────────────────────────┐ │ │ │ ┌──────────▼──────────┐ ┌────────────▼──────────┐ ┌────────────▼──────────┐ │ NiFi Registry │ │ NiFi Registry │ │ NiFi Registry │ │ Node 0 │ │ Node 1 │ │ Node 2 │ │ (LEADER) │ │ (FOLLOWER) │ │ (FOLLOWER) │ │ │ │ │ │ │ │ ┌─────────────────┐ │ │ ┌─────────────────┐ │ │ ┌─────────────────┐ │ │ │ H2 Database │ │ │ │ H2 Database │ │ │ │ H2 Database │ │ │ │ (authoritative │ │ │ │ (replica) │ │ │ │ (replica) │ │ │ │ for writes) │ │ │ └─────────────────┘ │ │ └─────────────────┘ │ │ └─────────────────┘ │ │ │ │ │ │ │ │ WriteReplicationFilter│ │ WriteReplicationFilter│ │ WriteReplicationFilter│ │ (307 → leader) │ │ (307 → leader) │ │ (fan-out to followers)│ │ │ │ │ └─────────────────────┘ └───────────────────────┘ └───────────────────────┘ │ ▲ ▲ └──── X-Registry-Replication fan-out ─────────────────┘

Traffic flows as follows:

  • Reads – Any node serves read requests from its local H2 database.

  • Writes to a follower – The follower returns 307 Temporary Redirect with the leader location. The client resends the request to the leader.

  • Writes to the leader – The leader commits the write locally, then replicates it to all followers through internal X-Registry-Replication requests.

Coordination modes

NiFi Registry supports database and zookeeper coordination modes.

Mode

Leader election

Cache invalidation

Database requirement

database (default)

TTL lease in the CLUSTER_LEADER table

Polls CACHE_VERSION every 15 seconds

Shared PostgreSQL or MySQL

zookeeper

Curator LeaderSelector

ZNode setData() push through CuratorCache

Local H2 database on each node

Recommendation: Use zookeeper mode when each node requires an isolated local H2 database. Use database mode when a shared RDBMS is available and ZooKeeper is not required.

Configure NiFi Registry HA

Configure the following properties in nifi-registry.properties on each Registry node.

# Enable HA nifi.registry.cluster.enabled=true nifi.registry.cluster.coordination=zookeeper # Node identity nifi.registry.cluster.node.identifier=registry-node-1 nifi.registry.cluster.node.address=https://node1:18443 # Shared internal authentication token # Use the same token on all nodes. The token must contain at least 64 hexadecimal characters. nifi.registry.cluster.node.internal.auth.token=<64-character-hex-string> # ZooKeeper configuration for zookeeper coordination mode nifi.registry.cluster.zookeeper.connect.string=zk1:2181,zk2:2181,zk3:2181 nifi.registry.cluster.zookeeper.root.node=/nifi-registry # Cache polling interval for database coordination mode nifi.registry.cluster.cache.refresh.interval.ms=15000 # HTTPS nifi.registry.web.https.host=<this-node-hostname> nifi.registry.web.https.port=18443

Set nifi.registry.cluster.coordination=database to use database coordination.

Use a unique value for nifi.registry.cluster.node.identifier and the correct node URL for nifi.registry.cluster.node.address on each node.

Custom Ambari Commands

The ambari-mpack provides the following custom commands for NiFi Registry maintenance:

  • ENABLE_READONLY_MODE – Activates MaintenanceModeFilter. The Registry rejects write requests with 503 Service Unavailable and continues to serve read requests. Run this command before planned maintenance.

  • DISABLE_READONLY_MODE – Deactivates maintenance mode and resumes write processing.

HA database tables

Database coordination uses the following HA tables.

-- Leader lease for database coordination mode. CREATE TABLE CLUSTER_LEADER ( id VARCHAR(100) PRIMARY KEY, -- Always 'SINGLETON' node_id VARCHAR(200) NOT NULL, acquired_at TIMESTAMP NOT NULL, expires_at TIMESTAMP NOT NULL -- 30-second TTL; renewed every 10 seconds ); -- Authorization cache version for database coordination mode. -- Increment this row to force all nodes to reload the authorization cache. CREATE TABLE CACHE_VERSION ( cache_name VARCHAR(200) PRIMARY KEY, version BIGINT NOT NULL DEFAULT 0 ); -- Cluster-wide event log. -- Ensures that EventHookProvider fires exactly once. CREATE TABLE REGISTRY_EVENT ( id VARCHAR(50) PRIMARY KEY, event_type VARCHAR(100) NOT NULL, payload CLOB, created_at TIMESTAMP NOT NULL, processed_at TIMESTAMP );


  Last updated