node.js loop crashed immediately when insert bulk data to cassandra -


I am trying to insert 1000000 data to the cassandra with nods. But the loop has crashed after a while. Every time I can not record more than 10000 records

Thank you.

My code looks like this:

  requires var Helenus = ('Helenus'), pool = new Helenas.connection pool ({host: [' localhost: 9160 '], keyspace:' twissandra ', user:' ', password:' ', timeout: 3000}); Pool.on ('Error', function (mistake) {console.error (err.name, err.message);}); Var i = 0; Pool.connect (function (err, keyspace) {if (err) {throw (err);} else {while (i & lt; 1000000) {i ++; var str = "tkg" + i; var pass = " Put in ktr "+ i" pool cql ("user (username, password) value (?,?)", [Str, pass], function (mistake, result) {});}}}; Console.log ("end");  

You may overload the cap Are once! Keep in mind that the request is asynchronous, so it has not already been completed.

Try using async.eachLimit to limit 50-100 requests at a time. Changes in the actual maximum concurrent capacity based on the backend process.


Comments