FlowFuse / flowfuse

Build bespoke, flexible, and resilient manufacturing low-code applications with FlowFuse and Node-RED
https://flowfuse.com
Other
265 stars 63 forks source link

Automatic failover for Node-RED Instances #1920

Open MarianRaphael opened 1 year ago

MarianRaphael commented 1 year ago

Description

Implement a robust automatic failover mechanism for Node-RED instances that focuses solely on high availability without considering scalability. This feature will monitor the active Node-RED instance and seamlessly switch to a hot-spare instance if the primary instance fails or becomes unresponsive, thus ensuring reliability without the added complexity of load balancing and scaling.

Related Epic

https://github.com/flowforge/flowforge/issues/1678

Assumption

Automatic failover without scaling is assumed to be easier to implement than a complete high availability solution with scaling, as it omits the complexities associated with load balancing, state management, and other challenges tied to scaling.

Motivation

As a customer of FlowForge, I would like to have the option to utilize high availability instances. This allows me to run business-critical processes within Node-RED and ensure that they are always available.

Key considerations

MarianRaphael commented 1 year ago

If the assumption is incorrect, the issue can be closed.

knolleary commented 1 year ago

@hardillb and I have been discussing how we will approach this at length to start building an implementation plan.

Our working notes are in https://www.figma.com/file/upA7oHb9seloP74kTMyegN/FlowForge-High-Availability-Design-notes?node-id=0%3A1&t=bZVnNEZIeQBpxH12-1

There is a lot of technical work required it isn't something you can do half the job, but we are starting to identify the steps needed to work towards it.

The key criteria is whether we can build a failover system that operates faster than it takes k8s to restart a crashed pod.

Current Architecture

image

HA Architecture

Lots more detail at the figma link above... copying here for reference

image

Key points

Restarting Node-RED

If the platform asks the HA Controller to restart Node-RED (could be updating settings or a staged deployment rollout), the HA Controller will notify the inactive instance to restart first - once it is ready, HA Controller will trigger a failover so the newly updated inactive instance becomes the active instance. It will then tell the newly inactive instance to restart. This will minimise the downtime of rolling out new flows.

There are a few different scenarios like this - some already documented in the figma doc.

Tasks

Two immediate tasks have been identified that can be got underway now:

From there, we then have to build the HA Controller. There's no short-cutting that piece - a finer grained task breakdown will follow for that.

MarianRaphael commented 1 year ago

Activities paused, based on workshop discussion. Alternative first approach: https://github.com/flowforge/flowforge/issues/2156