I've only just installed Node RED and I'm looking for a bit of direction for my project
I've created an application for my companies tracking devices that send cell tower and GPS data over mqtt and I was looking to load test it with hundreds of JSON messages a second!!, is this even feasible with Node RED??
load testing is certainly possible and "hundreds" of JSON messages should be achievable (though it will depend on how you have written flows and how large the data is etc) but I see no reason it cannot handle this volume.
I've only tried a single message so far from a flow I found in the cookbook.
So, the real world scenario is, we have nearly 1000 "tags" that dial in every 5 - 15 seconds with all the cell towers they can "see" from 1-15 along with a GPS coordinate, if available, and any public WiFi mac addresses, which we send off to a 3rd party service.
I have an application that will sit in between this to intercept, process, forward to 3rd party, intercept the response and finally forward back to the originating tag
So I would need to simulate a large number of devices each with there own unique ID, topic and a randomly generated JSON payload which I can publish to our broker, my app subscribes to the general topic, processes the data etc etc
Right now I just want to see what kind of load my application can handle so I just need to be able to generate a large number of random payloads to send at random intervals
I have a working flow that starts with an Inject button press, which generates a JSON object using a javascrip function and sends out the message to my MQTT broker with an mqqt out node and listens for the responce with an mqtt in node.
I can just copy paste the javascript function and mqtt nodes to run off the one inject node but that seems rather over kill especially if i need several hundred!!
Indeed. You can send more than one msg from a function. Use node.send or return an array.
I would likely configure the inject so that payload is a number (the number of messages to send). In the function, I would likely generate an array of size payload then fill it with random data. After the function node, I would add a delay, set to rate limit mode so as not to crucify the node runtime.
If you share your function (select function, press CTRL-E) I will show you how
for small flows, it is better to paste the JSON export into a code block:
``` type or paste code here ```
NOTE also, in your function, you are stringifying the JS Object before sending it to MQTT node. There is no need to do that (the MQTT node takes care of it)
Good catch, i was doing that because the recieving application takes the sequenceNUmber in as number and the MQTT out doesnt like the BigInt. But i've updated the reciving app to take in a string and set the nodes back to send the JSON obeject with the sequenceNumber as a string now.
I appreciate all the help you given.
So, if i wanted to ramp this up to say, 100 devices would you suggest using say, 10 funtions spitting out 10 devices each?? or could i use one function, with multiple outputs each it its own mqqt out node??
depends if the message structure is the same or different. If the same, i would write one function and create a visual subroutine using link-call - to minimise copy-pasta code!
no the reciveing application sits on a server, and its job is to take the JSON from the MQTT payload, process it and send back a response. The messages will ultimatly be coming from handheld tracking devices. These tests are just to product a high number of MQTT messages to see how it fairs before i relase it into the wild. Theoretically we could have 1000's of messages per second comming in and going out an we need to be able to scale the processing
the message structure will largely stay the same, thenumber of cell towers and/or wifi hotspots will increase, but these are in an array. I like that Link-call node, thats way better than having multiple functions i'd have to update.
from what i understand, the generate n object function outputs one long message, and the split literily splits them into seperate ones?? in your previous example Steve you didnt have a split
From your example i see 2 flows one for each device, but reusing the same function, again i could copy past them to have 10/20/50/100 devices but i sense there is way more refined way?
my MQTT topic string contains the unique deviceID, so i could have a linked function to generate these topics have another linked function to the generate the JSON payload and combine them, pass in the nodeRED topic & payload into the MQTT out node and bobs your uncle??
With this number of towers, topics and data, I'd for sure be looking very very hard at using SparkplugB vs MQTT.
The pro buffer compression, unified namespace and statefullness will be well worth getting it running at the start vs wishing you'd gone that way at tower 148.
Source. I use MQTT to send / receive ACARS messages from 2000+ aircraft at any time via Node-RED. SPb would have saved me sooooo much time, data and grief, but too late now.
Just Looking at SparkPlugB and from what i can tell its a standardization layer on top of MQTT, amongst other things. I'll deffo take a look to see if its suitable for our project, thanks for the heads up