Bulk update and insert using Meteor method call in loop making high cpu usage

Hello,

My application is on METEOR@1.6.0.1 and I am using reywood:publish-composite , matb33:collection-hooks for db relations.

I need to insert a list of 400 people into collection from excel file, for it currently i am inserting from client using Meteor method inside loop but when i see on galaxy during this CPU usage is very high 70-80% or some time 100%.

Once all data inserted, i need to send a mail and update the record so i am sending mail and update using Meteor method call one by one that again making CPU 70-80%.

How i can do above task in correct and efficient way. Please help.

Thanks.

Hello,

  1. Do not call the method from client to server to insert each time. Read and send all the necessary data, and then paste asynchronously into the database. Or even try mongo features such as insertMany or bulkOps. Or simply download the file and use mongoimport.
  2. You must understand that the packages you mentioned are not suitable for performance. And you should use them very carefully.
  3. Do not use sync loops.
3 Likes

Thanks @mrzafod , How i can insert asynchronously into the database without using loop?