Skip to content

Active/Standby Pairs for MLLP Interfaces

An active/standby pair is two QIE nodes in a High Availability cluster where only one node, the active node, takes load balancer traffic. The QIE database records which node is active. When the active node stops, the other node takes over its queued messages first and only then starts taking traffic, so messages keep the order they arrived in.

Qvera recommends this setup for HL7 MLLP interfaces that require first-in, first-out (FIFO) processing when the load balancer cannot keep each sender on one node by IP address. The pair adds failover, not throughput: one node does all the work while the other stands by. See First-In-First-Out (FIFO) Considerations for the other way to keep order.

Configure the Pair

Set the same Java options on both nodes:

-Dqie.haEngine=EnterpriseHAServiceImpl
-Dqie.probePort=8080
-Dqie.haActiveStandby=true

Point the load balancer's health check at the probe port on each node. Only the node that answers HTTP status 200 gets traffic. See Configure Probe Port for the probe port itself.

Select Process messages in order received on every channel that needs FIFO (see Process Messages in Order Received). The pair keeps order only on those channels.

Send every MLLP message through the load balancer. A sender must never connect to a node's own address (see Limits).

Qvera supports active/standby pairs on VM installations only, with exactly two nodes. In Kubernetes, a liveness check against the probe port, as in the example Kubernetes configuration, restarts the standby node because it answers 503. In a container, a node that the other node marks stopped exits with exit code 0 instead of restarting, so it comes back only under a restart policy that also restarts containers that exit normally, such as Docker's unless-stopped. With Docker's on-failure it stays down.

Which Node Is Active

When the pair starts, the first node to start normally becomes the active node, and it stays active until it stops. A node that starts while the other node is active answers HTTP status 503 (Service Unavailable) on its probe port and becomes the standby node. The roles do not switch back on their own unless a preferred primary node is set (see Preferred Primary Node).

Only the active node runs the work that QIE starts itself and that HA allows on one node at a time:

  • File, FTP, network share and database receivers poll for messages on the active node only.
  • Custom receivers and scheduled scripts that have Run script on all HA nodes cleared run on the active node only.
  • Destinations that have Limit this node to sending messages on only one HA instance. selected send from the active node only.

Receivers, scripts and destinations set to run on every node keep doing so on both nodes.

Each node logs a warning when it takes or loses the active role, and when it starts or stops answering 200 on its probe port.

Failover

The standby node answers 200 only after it has taken over the stopped node's queued messages. Messages on channels set to Process messages in order received are queued again in the order they arrived, ahead of anything new, so a failover does not change their order.

Clean Stop: When the active node is stopped, it marks itself as shut down in the database. The standby node notices within a few seconds, takes over the queued messages, and then answers 200. This typically takes about 15 seconds plus the time to queue the messages again.

Crash: When the active node fails without stopping, the standby node waits until the active node has missed 6 database check-ins (30 seconds with the default 5 second check-in interval). It then marks the active node as stopped and waits up to 20 seconds for it to report that it finished shutting down, in case it is still running. Then it takes over the queued messages and answers 200. A crash failover takes about one minute, and no node answers 200 during that time.

The number of missed check-ins is qie.instanceCheckinMissedCheckinCount, which defaults to 6 when qie.haActiveStandby is on. A higher value waits longer before a crashed node is taken over. A lower value takes over sooner, but a node that is only slow to check in is then more likely to be taken over and restarted.

Lost Database Connection

The active node stops answering 200 when it can no longer reach the database. It answers 503 once its last successful check-in is more than 20 seconds old, or more than one check-in interval plus 5 seconds when that is longer. This always happens before the standby node can take over, so the two nodes never answer 200 at the same time.

If the database comes back before the standby node takes over, the active node checks in and answers 200 again. If the standby node has already taken over, the node that lost the database finds that it was marked stopped, restarts, and comes back as the standby node.

When the database itself is unavailable, for example during a database restart or failover, both nodes miss their check-ins at the same time. A node whose own check-in has failed does not take over the other node until its own check-ins have succeeded again for the whole missed check-in window, 30 seconds by default. A preferred primary node in that state also waits until then before it marks the active node stopped. That gives the other node time to check in again, so the nodes do not take each other over, and no abnormal shutdown alert is raised for a node that is only slow to check in again. If the active node really has stopped, the failover takes up to that much longer.

Preferred Primary Node

To keep one node active whenever it is running, give it the lower qie.instancePriority:

-Dqie.instancePriority=1

Leave qie.instancePriority at its default of 99 on the other node. When the preferred node starts while the other node is active, it marks the active node as stopped. That node shuts down and restarts as the standby node, and the preferred node takes over its queued messages before it answers 200. No node answers 200 from the moment the active node starts shutting down until the takeover is complete.

The other node restarts every time the preferred node takes the active role back. This restart does not raise an abnormal shutdown alert. If the active node has not checked in for 20 seconds, the preferred node does not mark it stopped: the active node is taken over as after a crash, and the alert is raised. With equal priorities, which is the default, the active node stays active and there is no switching back.

Limits

Senders connect through the load balancer only. The standby node's listener ports stay open. A message sent straight to the standby node's address is processed there, out of order with the messages on the active node.

Only in-order channels keep their order. Channels that do not have Process messages in order received selected are not kept in order across a failover.

The load balancer must drop connections to a node that answers 503. When the active node loses the database, QIE does not close the connections senders already have open to it.

A node that loses only its own database connection can send messages twice. When the active node cannot reach the database but the standby node can, the standby node takes it over as after a crash (see Failover). If the active node reconnects before it has finished shutting down, it can still send messages it was holding, and the standby node sends the same messages again from the queue it took over. On channels set to Process messages in order received, those messages can also arrive out of order. The standby node waits no more than 20 seconds for the active node to finish shutting down, so that a crash failover stays within about one minute.

Microsoft SQL Server with in-memory tables. With qie.haUseInMemoryTables at its default of true, the record that names the active node is kept in a memory-optimized table, which is emptied when the database server restarts or an availability group fails over. The active node claims the record back at its next check-in. The standby node claims it only after it has taken over the active node's queued messages, as after a crash. A node that starts while the record is empty has not seen which node held it and can claim it at once; messages the previous active node still held can then be processed after newer ones. On MySQL and MariaDB the record is kept in a regular table and survives a database restart.

Enterprise HA only. qie.haActiveStandby has no effect unless qie.haEngine is set to EnterpriseHAServiceImpl. A standalone node answers its probe port as usual.