Is it okay to multiple process to write data to same file using writestream? what about the performance impact and data loss??
var fs = require('fs');
var cluster = require('cluster');
if(cluster.isMaster){
for(var i=0;i<10; i++)
{
var child = cluster.fork();
}
}
else{
var stream = fs.createWriteStream('data.txt', {flags:'a'});
stream.on('error', function(error){
console.log(process.pid+' error occured', error);
})
stream.write(process.pid+' msg\n');
//lots of writes
}