Answer the question
In order to leave comments, you need to log in
How to limit cpu usage for a function?
Good afternoon! We have a function that runs on all users and rewrites some parameters. The function is not critical and its execution time is not important. However, since a simple loop is used, everything is executed in turn, thus loading the processor at 100% and very slowing down the main application.
You can, of course, stick a timeout, but I would like to do it more elegantly and simply set some kind of priority for the execution of this function. Using nodejs under meteor.
Does anyone have any thoughts on this?
Answer the question
In order to leave comments, you need to log in
If you want to do it in NodeJS. At the moment, the maximum that you will do:
1) Run NodeJS in multi-threaded mode
2) You will use timers
3) 1 + 2
> users in one place, but there are still a bunch of tables, the data from which must be collected together and recorded in the user field.
Don't dig there. This needs to be resolved inside the database - for example, Postgres, stored procedures.
To drive data back and forth between the database and the application is empty. The database must be responsible for the integrity of the data.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question