FlowFuse / flowfuse

Connect, collect, transform, visualise, and interact with your Industrial Data in a single platform. Use FlowFuse to manage, scale and secure your Node-RED solutions.
https://flowfuse.com
Other
278 stars 63 forks source link

Scalability: TimerTasks #2793

Closed knolleary closed 9 months ago

knolleary commented 1 year ago

Description

Part of #2782

The Forge App runs some tasks on a regular schedule as part of its own house keeping. For example

Depending on the specific task, we may not want it running in multiple places at once. For example, the Trial Task isn't transactional - it gets the list of all subscriptions to operate on first, then does its thing. It would be possible for two instances to run in parallel, both get the same list and then both try to do the work.

Possible Solutions

Specific solutions will depend on the needs of the individual tasks and they will have to be considered on a case-by-case basis.

Some approaches will be:

  1. Rewrite tasks to be transactional and concurrency-safe
  2. Add jitter to the scheduling of the tasks so they don't run at the same time
  3. Add some sort of quorum holder capability so an instance takes a primary role to run the tasks... lots of dragons to be had here.

Epic/Story

2782

Have you provided an initial effort estimate for this issue?

I have provided an initial effort estimate

knolleary commented 10 months ago

We currently have 4 timerTasks to consider.

To simplify this task I think we only need to address the scheduling of the expireTokens task.

As for the others: