0

I want to write an program which will simulate data coming from some set of sensors. So I need some mechanism by which I can spawn few thousand threads which will send data to database at the same time (time stamp from all the threads has to be same) and then sleep for some time interval and then again send some data.

As spawning thousand threads will not be efficient and it might crash system I thought Node.js is better suited for this kind of requirement. Please correct me if I am wrong.

Can we do something like this using call back functions of Node.js? Or is there any other open source api/tool which can generate random time series kind of data?

1 Answer 1

2

JavaScript is single threaded, this includes Node. You could simulate this however by running multiple Node processes.

To communicate between processes you could use 0MQ Node bindings from: https://github.com/JustinTulloss/zeromq.node

Sign up to request clarification or add additional context in comments.

5 Comments

Hi, thanks for quick answer. Can we use callback functions for this purpose?
@Shekhar Callbacks won't execute concurrently, but you could use setTimeout or setInterval for the pause.
ohk. then I think I have to write multi threaded program, no other option.
@Shekhar do the request really not to come from 1000 different threads? Or do you just need really heavy penetration on your database?
well I just need to simulate data coming at regular intervals from large number of sensors/remote devices. I don't really need clients or requests

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.