1

I wrote a script that results in billions of documents inserted into a MongoDB collection. Not optimum, I know. When I tried to run it locally, it resulted in "FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - process out of memory".

Instead of running it on a localhost, I want to throw the .js file on a web server and run the file there.

Do I make changes to this code? Or upload file via FTP?

function mongoIfy(solution_JSONs){
// retrieve
var MongoClient = require('mongodb').MongoClient;
// Connect to the db
MongoClient.connect("mongodb://localhost:27017/slither_puzzle", function(err, db) {
  if(err) { return console.dir(err); }
  if(!err) {
    console.log("We are connected");

    var collection = db.collection('solutions');

    collection.insert(solution_JSONs)
  }
});
}

Thanks in advance!

Hope
  • 11
  • 1
  • This doesn't address your approach for a solution, but it might address your core problem: http://stackoverflow.com/questions/26094420/fatal-error-call-and-retry-last-allocation-failed-process-out-of-memory Basically assign more memory to node.js and consider a new JSON parser. – Ranger May 12 '16 at 16:11

0 Answers0