Requirements:
- Read the same register/parameter from each slave (IDs 1 → 100)
- Optimize the flow for low CPU utilization
- Ensure efficient polling (avoid unnecessary load or blocking)
- Insert/store each slave’s data into an SQL database
Current Challenges:
- Polling all 100 slaves efficiently without overloading CPU
- Managing timing / scheduling between requests
- Structuring the flow to scale cleanly
- Handling database writes without creating bottlenecks
Questions:
- What is the best approach to iterate through slave IDs (1–100) efficiently in Node-RED?
- Should I use a loop (function node) or split messages with delay/rate limiting?
- Is there a recommended pattern for Modbus polling (sequential vs parallel)?
- How can I batch or optimize SQL inserts for better performance?
- Any best practices for reducing CPU usage in such flows?
Additional Info:
- Using Modbus TCP
- Same register address for all slaves
- Open to using contrib nodes or custom function logic
Any examples, flow designs, or recommendations would be really helpful.
Thanks in advance!
jbudd
2
Welcome to the forum @adarshi.
100 modbus slaves sounds like quite a substantial setup.
Is this an industrial project, or perhaps an educational assignment?
Why do you need to minimise CPU usage?
Remember that Node-red is single threaded.
Maybe what you need is a compiled program, C for instance.
Have you considered paying a professional to write something for you?
Colin
3
How often do you need to poll?
I think it very unlikely that CPU usage is going to be a problem. The s/w will be spending most of its time waiting for the slaves.
What sort of hardware will node red be running on?
Is the mysql server running on the same machine as node red?
Thanks for your response!
Here are the details:
- Polling interval: I need to read data every 1 to 5 seconds
- Environment: Node-RED is running on a Windows Server machine
- Database: Microsoft SQL Server (MSSQL) is running on the same machine
yes this is an industrial project.
CPU usage become 100%.
jbudd
5
I VERY surprised that you are hitting 100% CPU usage.
Have you checked for loops in your Node-red code? Backlogs in db operations?
An obvious thing to try would be to run Node-red and the db on different servers.
Colin
6
What process becomes 100%?
Can you stop node red and then start it again in a command window and post the startup log here. Copy/paste text please, not screenshot.
Aaqu
7
Are all 100 slaves behind a single IP gateway, or does each slave have its own IP address?