S
S
Sergey Savostin2015-03-04 11:20:50
Node.js
Sergey Savostin, 2015-03-04 11:20:50

Would such a Node.js daemon structure be correct?

As a practical warm-up while learning Node.js, I decided to try rewriting my data handler.
Now implemented in php: by cron, one script receives a list of tasks from the database and runs another php script (hundreds) in the background to complete the task (the task consists of obtaining data via http from hundreds of sources, JSON processing, calculations and folding into the database and files) . I do not like a huge number of processes, well, in terms of memory consumption, IMHO should feel better.
Unfortunately, all examples on the Internet implement a web application / server. I must have a daemon/client. Well, maybe some kind of web muzzle for viewing statistics / downloads, but that's later.
Schematically, I have this:

var connection = mysql.createConnection(...); // ничего, что соединение одно? в job.start его можно использовать?
var core = setInterval(function() {
   connection.query('SELECT job FROM jobs', {}, function(err, res){ // получить работу
      res.forEach(function(job){
         job.start(); // собственно работа
      });
   });
}, 60000); //раз в минуту получить задания

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey, 2015-03-04
Protko @Fesor

1) you won't get much performance/memory gain. For reference - the node eats more memory than puff.
2) look towards queues (ZeroMQ, RabbutMQ, Resque)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question