sourced-repo-mongo
sourced-repo-mongo copied to clipboard
Performance vs reliability question
Are there certain considerations / concessions you would make with a data model in a situation where every single event is 100% mission critical? Specifically regarding this code:
self.events.insertMany(events, function (err) {
if (err) return cb(err);
log('committed %s.events for id %s', self.entityType.name, entity.id);
entity.newEvents = [];
return cb();
});
Since these writes are only atomic at the individual event level, how do you handle a potential write failure with a single event in a list of events? Would this be something you'd consider self-healing with a replay? Would you programmatically trigger a replay based on a failure here? Could you mitigate this risk more by only ever writing 1 event at a time in a "message" handler?
Thanks!