MongoDB教育訓練-20211223-02
- 資料先寫入記憶體 ,
當資訊不同步,server 必須 rollback 確保資訊一致 => { x: 100} (移除)
The case for Majority writes
in the previeous scenario:
date is writtten to the primary
primary acknowledges write to application
primary dies before secondary reads data
必須所以資料到達大多數節點(majoruty commit point),才能稱之為持久化
- OK, commitresd 意義
var wc = { w: 0 }
totalrecs = 10000
batchsize = 1
nbatches = totalrecs / batchsize
var start = new Date()
for(x=0;x<nbatches;x++) {
recs = []
for(y=0;y<batchsize;y++) {recs.push({a:1,b:"hello"})}
db.test.insertMany(recs,{writeConcern: wc})
}
var end=new Date()
print(`${end-start} milliseconds`)








