KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB
-
Upload
rakuten-inc -
Category
Technology
-
view
4.423 -
download
4
description
Transcript of KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB
![Page 1: KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB](https://reader034.fdocument.pub/reader034/viewer/2022052619/55614fbfd8b42a857d8b4e66/html5/thumbnails/1.jpg)
1 楽天株式会社 開発部 アーキテクトG 窪田 博昭 | 2012年1月18日
KVSの性能
RDBMSのインデックス
更にMapReduceを併せ持つ
All-in-one NoSQL
![Page 2: KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB](https://reader034.fdocument.pub/reader034/viewer/2022052619/55614fbfd8b42a857d8b4e66/html5/thumbnails/2.jpg)
2
• Introduction
• How to use mongo on the news.infoseek.co.jp
Agenda
Introduction
![Page 3: KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB](https://reader034.fdocument.pub/reader034/viewer/2022052619/55614fbfd8b42a857d8b4e66/html5/thumbnails/3.jpg)
3
Introduction
![Page 4: KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB](https://reader034.fdocument.pub/reader034/viewer/2022052619/55614fbfd8b42a857d8b4e66/html5/thumbnails/4.jpg)
4
Who am I ?
![Page 5: KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB](https://reader034.fdocument.pub/reader034/viewer/2022052619/55614fbfd8b42a857d8b4e66/html5/thumbnails/5.jpg)
5
Name: 窪田 博昭 Hiroaki Kubota
Company: Rakuten Inc.
Unit: ACT = Development Unit Architect Group
Mail: [email protected]
Hobby: Futsal , Golf
Recent: My physical power has gradual declined...
twitter : crumbjp
github: crumbjp
Profile
Introduction
![Page 6: KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB](https://reader034.fdocument.pub/reader034/viewer/2022052619/55614fbfd8b42a857d8b4e66/html5/thumbnails/6.jpg)
6
How to take advantages of the Mongo
for the infoseek news
![Page 7: KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB](https://reader034.fdocument.pub/reader034/viewer/2022052619/55614fbfd8b42a857d8b4e66/html5/thumbnails/7.jpg)
7
For instance of our page
![Page 8: KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB](https://reader034.fdocument.pub/reader034/viewer/2022052619/55614fbfd8b42a857d8b4e66/html5/thumbnails/8.jpg)
8
Page structure
![Page 9: KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB](https://reader034.fdocument.pub/reader034/viewer/2022052619/55614fbfd8b42a857d8b4e66/html5/thumbnails/9.jpg)
9
Layout / Components
Layout Components
![Page 10: KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB](https://reader034.fdocument.pub/reader034/viewer/2022052619/55614fbfd8b42a857d8b4e66/html5/thumbnails/10.jpg)
10
Albatross structure
Internet
WEB
API
ContentsDB MongoDB
ReplSet
Gat page layout
Request LayoutDB
MongoDB
ReplSet Call APIs
Retrieve data
Get components
SessionDB
MongoDB
ReplSet
Memcache
![Page 11: KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB](https://reader034.fdocument.pub/reader034/viewer/2022052619/55614fbfd8b42a857d8b4e66/html5/thumbnails/11.jpg)
11
CMS
Developer
Albatross structure
API servers
ContentsDB MongoDB
ReplSet
Set page layout HTML markup
&
API settings
LayoutDB
MongoDB
ReplSet
Deploy API
Set components
Batch servers
Insert Data
![Page 12: KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB](https://reader034.fdocument.pub/reader034/viewer/2022052619/55614fbfd8b42a857d8b4e66/html5/thumbnails/12.jpg)
12
CMS
Layout editor
![Page 13: KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB](https://reader034.fdocument.pub/reader034/viewer/2022052619/55614fbfd8b42a857d8b4e66/html5/thumbnails/13.jpg)
13
CMS
![Page 14: KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB](https://reader034.fdocument.pub/reader034/viewer/2022052619/55614fbfd8b42a857d8b4e66/html5/thumbnails/14.jpg)
14
CMS
![Page 15: KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB](https://reader034.fdocument.pub/reader034/viewer/2022052619/55614fbfd8b42a857d8b4e66/html5/thumbnails/15.jpg)
15
MapReduce
![Page 16: KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB](https://reader034.fdocument.pub/reader034/viewer/2022052619/55614fbfd8b42a857d8b4e66/html5/thumbnails/16.jpg)
16
We have never used MapReduce as regular operation.
However, We have used it for some irreglar case.
• To search the invalid articles that should be removed because of someone’s mistakes...
• To analyze the number of new articles posted a day.
• To analyze the updated number an article.
• We get start considering to use it regularly for the social data analyzing before long ...
Our usage
MapReduce
![Page 17: KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB](https://reader034.fdocument.pub/reader034/viewer/2022052619/55614fbfd8b42a857d8b4e66/html5/thumbnails/17.jpg)
17
Structure & Performance
![Page 18: KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB](https://reader034.fdocument.pub/reader034/viewer/2022052619/55614fbfd8b42a857d8b4e66/html5/thumbnails/18.jpg)
18
Structure
• Intel(R) Xeon(R) CPU X5650 2.67GHz 1core!!
• 4GB memory
• 50 GB disk space ( iScsi )
• CentOS5.5 64bit
• mongodb 1.8.0
– ReplicaSet 5 nodes ( + 1 Arbiter)
– Oplog size 1.2GB
– Average object size 1KB
We are using very poor machine (Virtual machine) !!
![Page 19: KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB](https://reader034.fdocument.pub/reader034/viewer/2022052619/55614fbfd8b42a857d8b4e66/html5/thumbnails/19.jpg)
19
Structure
We’ve also researched following environments...
• Virtual machine 1 core
– 1kb data , 6,000,000 documents
– 8kb data , 200,000 documents
• Virtual machine 3 core
– 1kb data , 6,000,000 documents
– 8kb data , 200,000 documents
• EC2 large instance
– 2kb data , 60,000,000 documents. ( 100GB )
Researched environment
![Page 20: KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB](https://reader034.fdocument.pub/reader034/viewer/2022052619/55614fbfd8b42a857d8b4e66/html5/thumbnails/20.jpg)
20
Performance
1~8 kb documents + 1 unique index
C = Number of CPU cores (Xeon 2.67 GHz)
DD = Score of ‘dd’ command (byte/sec)
S = Document size (byte)
• GET qps = 4500 × C
• SET(fsync) bytes/s = 0.05×DD ÷ S
• SET(nsync) qps = 4500 BUT...
have chance of STALE
I found the formula for making a rough estimation of QPS
![Page 21: KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB](https://reader034.fdocument.pub/reader034/viewer/2022052619/55614fbfd8b42a857d8b4e66/html5/thumbnails/21.jpg)
21
Performance example (on EC2 large)
![Page 22: KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB](https://reader034.fdocument.pub/reader034/viewer/2022052619/55614fbfd8b42a857d8b4e66/html5/thumbnails/22.jpg)
22
Performance example (on EC2 large)
Data-type
{
shop: 'someone',
item: 'something',
description: 'item explanation sentences...‘
}
EC2 large instance
– 2kb data , 60,000,000 documents. ( 100GB )
– 1 unique index
Environment and amount of data
![Page 23: KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB](https://reader034.fdocument.pub/reader034/viewer/2022052619/55614fbfd8b42a857d8b4e66/html5/thumbnails/23.jpg)
23
Performance example (on EC2 large)
Batch insert (1000 documents) fsync=true
17906 sec (=289 min) (=3358 docs/sec)
Ensure index (background=false)
4049 sec (=67min)
1. primary 2101 sec (=35min)
2. secondary 1948 sec (=32min)
![Page 24: KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB](https://reader034.fdocument.pub/reader034/viewer/2022052619/55614fbfd8b42a857d8b4e66/html5/thumbnails/24.jpg)
24
Performance example (on EC2 large)
Add one node
5833sec (=97min)
1. Get files 2GB×48 2120 sec (=35min)
2. _id indexing 1406 sec (=23min)
3. uniq indexing 2251 sec (=38min)
4. other processes 56 sec (=1 min)
![Page 25: KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB](https://reader034.fdocument.pub/reader034/viewer/2022052619/55614fbfd8b42a857d8b4e66/html5/thumbnails/25.jpg)
25
Performance example (on EC2 large)
Group by
• Reduce by unique index & map & reduce
– 368 msec
db.data.group({ key: { shop: 1},
cond: { shop: 'someone' },
reduce: function ( o , p ) { p.sum++; },
initial: { sum: 0 } });
![Page 26: KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB](https://reader034.fdocument.pub/reader034/viewer/2022052619/55614fbfd8b42a857d8b4e66/html5/thumbnails/26.jpg)
26
Performance example (on EC2 large)
MapReduce
• Scan all data 3116sec (=52min)
– number of key = 39092
db.data.mapReduce(
function(){ emit(this.shop,1); },
function(k,v){
var ret=0;
v.forEach( function (value){ ret+=value; });
return ret; },
{ query: {}, inline: 1, out: 'Tmp' } );
![Page 27: KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB](https://reader034.fdocument.pub/reader034/viewer/2022052619/55614fbfd8b42a857d8b4e66/html5/thumbnails/27.jpg)
27
Major problems...
![Page 28: KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB](https://reader034.fdocument.pub/reader034/viewer/2022052619/55614fbfd8b42a857d8b4e66/html5/thumbnails/28.jpg)
28
Indexing
![Page 29: KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB](https://reader034.fdocument.pub/reader034/viewer/2022052619/55614fbfd8b42a857d8b4e66/html5/thumbnails/29.jpg)
29
Index probrem
Indexing is lock operation in default.
Indexing operation can run as background
on the primary. But...
It CANNOT run as background on the secondary
Moreover the all secondary’s indexing run
at the same time !!
Result in above...
All slave freezes ! orz...
Online indexisng is completely useless even if last version (2.0.2)
![Page 30: KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB](https://reader034.fdocument.pub/reader034/viewer/2022052619/55614fbfd8b42a857d8b4e66/html5/thumbnails/30.jpg)
30
Present indexing ( default )
![Page 31: KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB](https://reader034.fdocument.pub/reader034/viewer/2022052619/55614fbfd8b42a857d8b4e66/html5/thumbnails/31.jpg)
31
Index probrem
Present indexing ( default )
Secondary
Secondary Secondary
Client Client Client Client Client
Batch
Primary save
![Page 32: KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB](https://reader034.fdocument.pub/reader034/viewer/2022052619/55614fbfd8b42a857d8b4e66/html5/thumbnails/32.jpg)
32
Index probrem
Present indexing ( default )
ensureIndex Primary
Lock
Indexing
Secondary
Secondary Secondary
Client Client Client Client Client
Batch Cannot write
![Page 33: KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB](https://reader034.fdocument.pub/reader034/viewer/2022052619/55614fbfd8b42a857d8b4e66/html5/thumbnails/33.jpg)
33
Index probrem
Present indexing ( default )
Cannot read !!
SYNC SYNC SYNC
Secondary
Lock
Indexing
Secondary
Lock
Indexing
Secondary
Lock
Indexing
Client Client Client Client Client
Primary
Complete Batch
finished
![Page 34: KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB](https://reader034.fdocument.pub/reader034/viewer/2022052619/55614fbfd8b42a857d8b4e66/html5/thumbnails/34.jpg)
34
Index probrem
Ideal indexing ( default )
Secondary
Complete
Secondary
Complete
Secondary
Complete
Client Client Client Client Client
Primary
Complete Batch
![Page 35: KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB](https://reader034.fdocument.pub/reader034/viewer/2022052619/55614fbfd8b42a857d8b4e66/html5/thumbnails/35.jpg)
35
Present indexing ( background )
![Page 36: KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB](https://reader034.fdocument.pub/reader034/viewer/2022052619/55614fbfd8b42a857d8b4e66/html5/thumbnails/36.jpg)
36
Index probrem
Present indexing ( background )
Secondary
Secondary Secondary
Client Client Client Client Client
Batch
Primary save
![Page 37: KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB](https://reader034.fdocument.pub/reader034/viewer/2022052619/55614fbfd8b42a857d8b4e66/html5/thumbnails/37.jpg)
37
Index probrem
Present indexing ( background )
Primary
Slowdown
Indexing
Secondary
Secondary Secondary
Client Client Client Client Client
Batch ensureIndex(background) Slow down...
![Page 38: KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB](https://reader034.fdocument.pub/reader034/viewer/2022052619/55614fbfd8b42a857d8b4e66/html5/thumbnails/38.jpg)
38
Index probrem
Present indexing ( background )
Cannot read !!
SYNC SYNC SYNC
Secondary
Lock
Indexing
Secondary
Lock
Indexing
Secondary
Lock
Indexing
Client Client Client Client Client
Primary
Complete Batch
finished
![Page 39: KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB](https://reader034.fdocument.pub/reader034/viewer/2022052619/55614fbfd8b42a857d8b4e66/html5/thumbnails/39.jpg)
39
Index probrem
Present indexing ( background )
Cannot read !!
SYNC SYNC SYNC
Secondary
Lock
Indexing
Secondary
Lock
Indexing
Secondary
Lock
Indexing
Client Client Client Client Client
Primary
Complete Batch
finished
Background indexing don’t work
on the secondaries
![Page 40: KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB](https://reader034.fdocument.pub/reader034/viewer/2022052619/55614fbfd8b42a857d8b4e66/html5/thumbnails/40.jpg)
40
Index probrem
Present indexing ( background )
Cannot read !!
SYNC SYNC SYNC
Secondary
Lock
Indexing
Secondary
Lock
Indexing
Secondary
Lock
Indexing
Client Client Client Client Client
Primary
Complete Batch
finished
![Page 41: KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB](https://reader034.fdocument.pub/reader034/viewer/2022052619/55614fbfd8b42a857d8b4e66/html5/thumbnails/41.jpg)
41
Index probrem
Ideal indexing ( background )
Secondary
Complete
Secondary
Complete
Secondary
Complete
Client Client Client Client Client
Primary
Complete Batch
![Page 42: KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB](https://reader034.fdocument.pub/reader034/viewer/2022052619/55614fbfd8b42a857d8b4e66/html5/thumbnails/42.jpg)
42
Probable 2.1.X indexing
![Page 43: KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB](https://reader034.fdocument.pub/reader034/viewer/2022052619/55614fbfd8b42a857d8b4e66/html5/thumbnails/43.jpg)
43
Index probrem
But not released formally.
So I checked out the source code up to date.
Certainlly it’ll be fixed !
Moreover it sounds like it’ll run as foreground
when slave status isn’t SECONDARY
(it means RECOVERING )
Accoding to mongodb.org this probrem will fix in 2.1.0
![Page 44: KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB](https://reader034.fdocument.pub/reader034/viewer/2022052619/55614fbfd8b42a857d8b4e66/html5/thumbnails/44.jpg)
44
Index probrem
Secondary
Secondary Secondary
Client Client Client Client Client
Batch
Primary save
Probable 2.1.X indexing
![Page 45: KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB](https://reader034.fdocument.pub/reader034/viewer/2022052619/55614fbfd8b42a857d8b4e66/html5/thumbnails/45.jpg)
45
Index probrem
Probable 2.1.X indexing
Secondary
Secondary Secondary
ensureIndex(background)
Client Client Client Client Client
Batch
Primary
Slowdown
Indexing
Slow down...
![Page 46: KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB](https://reader034.fdocument.pub/reader034/viewer/2022052619/55614fbfd8b42a857d8b4e66/html5/thumbnails/46.jpg)
46
SYNC
Index probrem
Slow down...
SYNC SYNC
Secondary
Slowdown
Indexing
Secondary
Slowdown
Indexing
Secondary
Slowdown
Indexing
Probable 2.1.X indexing
Client Client Client Client Client
Primary
Complete Batch
finished
![Page 47: KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB](https://reader034.fdocument.pub/reader034/viewer/2022052619/55614fbfd8b42a857d8b4e66/html5/thumbnails/47.jpg)
47
Index probrem
Secondary
Complete
Secondary
Complete
Secondary
Complete
Client Client Client Client Client
Primary
Complete
Probable 2.1.X indexing
Batch
![Page 48: KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB](https://reader034.fdocument.pub/reader034/viewer/2022052619/55614fbfd8b42a857d8b4e66/html5/thumbnails/48.jpg)
48
Index probrem
But I think it’s not enough.
I think it can be fatal for the system that
the all secondaries slowdown at the same time !!
So...
Background indexing 2.1.X
![Page 49: KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB](https://reader034.fdocument.pub/reader034/viewer/2022052619/55614fbfd8b42a857d8b4e66/html5/thumbnails/49.jpg)
49
Ideal indexing
![Page 50: KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB](https://reader034.fdocument.pub/reader034/viewer/2022052619/55614fbfd8b42a857d8b4e66/html5/thumbnails/50.jpg)
50
Index probrem
Secondary
Secondary Secondary
Client Client Client Client Client
Batch
Primary save
Ideal indexing
![Page 51: KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB](https://reader034.fdocument.pub/reader034/viewer/2022052619/55614fbfd8b42a857d8b4e66/html5/thumbnails/51.jpg)
51
Index probrem
Ideal indexing
Secondary
Secondary Secondary
ensureIndex(background)
Client Client Client Client Client
Batch
Primary
Slowdown
Indexing
Slow down...
![Page 52: KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB](https://reader034.fdocument.pub/reader034/viewer/2022052619/55614fbfd8b42a857d8b4e66/html5/thumbnails/52.jpg)
52
Index probrem
Ideal indexing
ensureIndex
Recovering
Indexing
Secondary
Secondary
Client Client Client Client Client
finished Primary
Complete Batch
![Page 53: KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB](https://reader034.fdocument.pub/reader034/viewer/2022052619/55614fbfd8b42a857d8b4e66/html5/thumbnails/53.jpg)
53
Index probrem
Ideal indexing
ensureIndex
Secondary
Complete
Recovering
Indexing
Secondary
Client Client Client Client Client
Batch
Primary
Complete
![Page 54: KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB](https://reader034.fdocument.pub/reader034/viewer/2022052619/55614fbfd8b42a857d8b4e66/html5/thumbnails/54.jpg)
54
Index probrem
Ideal indexing
ensureIndex
Secondary
Complete
Secondary
Complete
Recovering
Indexing
Client Client Client Client Client
Batch
Primary
Complete
![Page 55: KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB](https://reader034.fdocument.pub/reader034/viewer/2022052619/55614fbfd8b42a857d8b4e66/html5/thumbnails/55.jpg)
55
Index probrem
Ideal indexing
Secondary
Complete
Secondary
Complete
Secondary
Complete
Client Client Client Client Client
Primary
Complete Batch
![Page 56: KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB](https://reader034.fdocument.pub/reader034/viewer/2022052619/55614fbfd8b42a857d8b4e66/html5/thumbnails/56.jpg)
56
Index probrem
It would be great if I can operate indexing manually
at each secondaries
But ... I easilly guess it’s difficult to apply for current Oplog
![Page 57: KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB](https://reader034.fdocument.pub/reader034/viewer/2022052619/55614fbfd8b42a857d8b4e66/html5/thumbnails/57.jpg)
57
I suggest Manual indexing
![Page 58: KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB](https://reader034.fdocument.pub/reader034/viewer/2022052619/55614fbfd8b42a857d8b4e66/html5/thumbnails/58.jpg)
58
Index probrem
Secondary
Secondary Secondary
Client Client Client Client Client
Batch
Primary save
Manual indexing
![Page 59: KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB](https://reader034.fdocument.pub/reader034/viewer/2022052619/55614fbfd8b42a857d8b4e66/html5/thumbnails/59.jpg)
59
Index probrem
Manual indexing
Secondary
Secondary Secondary
Client Client Client Client Client
Batch
Primary
Slowdown
Indexing
Slow down... ensureIndex(manual,background)
![Page 60: KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB](https://reader034.fdocument.pub/reader034/viewer/2022052619/55614fbfd8b42a857d8b4e66/html5/thumbnails/60.jpg)
60
Index probrem
Manual indexing
finished Primary
Complete Batch
Secondary
Secondary
Secondary
Client Client Client Client Client
![Page 61: KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB](https://reader034.fdocument.pub/reader034/viewer/2022052619/55614fbfd8b42a857d8b4e66/html5/thumbnails/61.jpg)
61
Index probrem
Manual indexing
finished Primary
Complete Batch
Secondary
Secondary
Secondary
Client Client Client Client Client
The secondaries don’t sync
automatically
![Page 62: KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB](https://reader034.fdocument.pub/reader034/viewer/2022052619/55614fbfd8b42a857d8b4e66/html5/thumbnails/62.jpg)
62
Index probrem
Manual indexing
finished Primary
Complete Batch
Secondary
Secondary
Secondary
Client Client Client Client Client
![Page 63: KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB](https://reader034.fdocument.pub/reader034/viewer/2022052619/55614fbfd8b42a857d8b4e66/html5/thumbnails/63.jpg)
63
Index probrem
Manual indexing
Recovering
Indexing
Secondary
Secondary
Client Client Client Client Client
ensureIndex(manual)
Primary
Complete Batch
![Page 64: KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB](https://reader034.fdocument.pub/reader034/viewer/2022052619/55614fbfd8b42a857d8b4e66/html5/thumbnails/64.jpg)
64
Index probrem
Manual indexing
Secondary
Complete
Recovering
Indexing
Secondary
Client Client Client Client Client
ensureIndex(manual)
Primary
Complete Batch
![Page 65: KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB](https://reader034.fdocument.pub/reader034/viewer/2022052619/55614fbfd8b42a857d8b4e66/html5/thumbnails/65.jpg)
65
Index probrem
Manual indexing
Secondary
Complete
Secondary
Complete
Secondary
Slowdown
Indexing
Client Client Client Client Client
ensureIndex(manual,background)
Primary
Complete Batch
![Page 66: KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB](https://reader034.fdocument.pub/reader034/viewer/2022052619/55614fbfd8b42a857d8b4e66/html5/thumbnails/66.jpg)
66
Index probrem
Manual indexing
Secondary
Complete
Secondary
Complete
Secondary
Slowdown
Indexing
Client Client Client Client Client
ensureIndex(manual,background)
Primary
Complete Batch
It needs to support
background operation
Just in case,if the ReplSet has only
one Secondary
![Page 67: KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB](https://reader034.fdocument.pub/reader034/viewer/2022052619/55614fbfd8b42a857d8b4e66/html5/thumbnails/67.jpg)
67
Index probrem
Manual indexing
Secondary
Complete
Secondary
Complete
Secondary
Slowdown
Indexing
Client Client Client Client Client
ensureIndex(manual,background)
Primary
Complete Batch
![Page 68: KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB](https://reader034.fdocument.pub/reader034/viewer/2022052619/55614fbfd8b42a857d8b4e66/html5/thumbnails/68.jpg)
68
Index probrem
Manual indexing
Secondary
Complete
Secondary
Complete
Secondary
Complete
Client Client Client Client Client
Primary
Complete Batch
![Page 69: KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB](https://reader034.fdocument.pub/reader034/viewer/2022052619/55614fbfd8b42a857d8b4e66/html5/thumbnails/69.jpg)
69
That’s all about Indexing problem
![Page 70: KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB](https://reader034.fdocument.pub/reader034/viewer/2022052619/55614fbfd8b42a857d8b4e66/html5/thumbnails/70.jpg)
70
Struggle to control the sync
![Page 71: KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB](https://reader034.fdocument.pub/reader034/viewer/2022052619/55614fbfd8b42a857d8b4e66/html5/thumbnails/71.jpg)
71
STALE
![Page 72: KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB](https://reader034.fdocument.pub/reader034/viewer/2022052619/55614fbfd8b42a857d8b4e66/html5/thumbnails/72.jpg)
72
Unknown log & Out of control the ReplSet
• Secondaries change status repeatedly in a moment
between Secondary and Recovering (1.8.0)
• Then we found the strange line in the log...
[rsSync] replSet error RS102 too stale to catch up
We often suffered from going out of control the Secondaries...
![Page 73: KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB](https://reader034.fdocument.pub/reader034/viewer/2022052619/55614fbfd8b42a857d8b4e66/html5/thumbnails/73.jpg)
73
What’s Stale ?
• 〈食品・飲料などが〉新鮮でない(⇔fresh);
• 気の抜けた, 〈コーヒーが〉香りの抜けた,
• 〈パンが〉ひからびた, 堅くなった,
• 〈空気・臭(にお)いなどが〉むっとする,
• いやな臭いのする
stale [stéil] (レベル:社会人必須 ) powered by goo.ne.jp
![Page 74: KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB](https://reader034.fdocument.pub/reader034/viewer/2022052619/55614fbfd8b42a857d8b4e66/html5/thumbnails/74.jpg)
74
What’s Stale ?
• 〈食品・飲料などが〉新鮮でない(⇔fresh);
• 気の抜けた, 〈コーヒーが〉香りの抜けた,
• 〈パンが〉ひからびた, 堅くなった,
• 〈空気・臭(にお)いなどが〉むっとする,
• いやな臭いのする
どうも非常によろしくないらしい・・・
stale [stéil] (レベル:社会人必須 ) powered by goo.ne.jp
![Page 75: KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB](https://reader034.fdocument.pub/reader034/viewer/2022052619/55614fbfd8b42a857d8b4e66/html5/thumbnails/75.jpg)
75
Mechanizm of being stale
![Page 76: KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB](https://reader034.fdocument.pub/reader034/viewer/2022052619/55614fbfd8b42a857d8b4e66/html5/thumbnails/76.jpg)
76
ReplicaSet
Primary
Database Oplog
Client
Secondary
Database
mongod mongod
Oplog
![Page 77: KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB](https://reader034.fdocument.pub/reader034/viewer/2022052619/55614fbfd8b42a857d8b4e66/html5/thumbnails/77.jpg)
77
Replication (simple case)
![Page 78: KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB](https://reader034.fdocument.pub/reader034/viewer/2022052619/55614fbfd8b42a857d8b4e66/html5/thumbnails/78.jpg)
78
ReplicaSet
Primary
Database Oplog
Client
Secondary
Database
mongod mongod
Oplog
![Page 79: KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB](https://reader034.fdocument.pub/reader034/viewer/2022052619/55614fbfd8b42a857d8b4e66/html5/thumbnails/79.jpg)
79
Insert & Replication 1
Primary
Database Oplog
Client
Secondary
Database
Insert A
A
A
Insert
mongod mongod
Oplog
![Page 80: KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB](https://reader034.fdocument.pub/reader034/viewer/2022052619/55614fbfd8b42a857d8b4e66/html5/thumbnails/80.jpg)
80
Insert & Replication 1
Primary
Database Oplog
Client
Secondary
Database
Insert A
A A
Oplog
Insert A
Sync
![Page 81: KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB](https://reader034.fdocument.pub/reader034/viewer/2022052619/55614fbfd8b42a857d8b4e66/html5/thumbnails/81.jpg)
81
Replication (busy case)
![Page 82: KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB](https://reader034.fdocument.pub/reader034/viewer/2022052619/55614fbfd8b42a857d8b4e66/html5/thumbnails/82.jpg)
82
Stale
Primary
Database Oplog
Client
Secondary
Database
Insert A
A A
Oplog
Insert A
mongod mongod
![Page 83: KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB](https://reader034.fdocument.pub/reader034/viewer/2022052619/55614fbfd8b42a857d8b4e66/html5/thumbnails/83.jpg)
83
Insert & Replication 2
Primary
Database Oplog
Client
Secondary
Database
Insert A
B
A
Insert
B
Insert B
A
Oplog
Insert A
![Page 84: KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB](https://reader034.fdocument.pub/reader034/viewer/2022052619/55614fbfd8b42a857d8b4e66/html5/thumbnails/84.jpg)
84
Insert & Replication 2
Primary
Database Oplog
Client
Secondary
Database
Insert A
C
A
Insert
B
Insert B
A
C
Insert C
Oplog
Insert A
![Page 85: KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB](https://reader034.fdocument.pub/reader034/viewer/2022052619/55614fbfd8b42a857d8b4e66/html5/thumbnails/85.jpg)
85
Insert & Replication 2
Primary
Database Oplog
Client
Secondary
Database
Insert A
A
A
Update
B
Insert B
A
C
Insert C
Update A
Oplog
Insert A
![Page 86: KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB](https://reader034.fdocument.pub/reader034/viewer/2022052619/55614fbfd8b42a857d8b4e66/html5/thumbnails/86.jpg)
86
Insert & Replication 2
Primary
Database Oplog
Client
Secondary
Database
Insert A
A
B
Insert B
A
C
Insert C
Update A
Oplog
Insert A
Check Oplog
![Page 87: KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB](https://reader034.fdocument.pub/reader034/viewer/2022052619/55614fbfd8b42a857d8b4e66/html5/thumbnails/87.jpg)
87
Insert & Replication 2
Primary
Database Oplog
Client
Secondary
Database
Insert A
A
B
Insert B C
Insert C
Update A
Oplog
Insert A
Sync
Insert B
Insert C
Update A
A
B
C
![Page 88: KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB](https://reader034.fdocument.pub/reader034/viewer/2022052619/55614fbfd8b42a857d8b4e66/html5/thumbnails/88.jpg)
88
Replication (more busy)
![Page 89: KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB](https://reader034.fdocument.pub/reader034/viewer/2022052619/55614fbfd8b42a857d8b4e66/html5/thumbnails/89.jpg)
89
Stale
Primary
Database Oplog
Client
Secondary
Database
Insert A
A A
Oplog
Insert A
mongod mongod
![Page 90: KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB](https://reader034.fdocument.pub/reader034/viewer/2022052619/55614fbfd8b42a857d8b4e66/html5/thumbnails/90.jpg)
90
Stale
Primary
Database Oplog
Client
Secondary
Database
Insert A
B
A
Insert
B
Insert B
A
Oplog
Insert A
![Page 91: KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB](https://reader034.fdocument.pub/reader034/viewer/2022052619/55614fbfd8b42a857d8b4e66/html5/thumbnails/91.jpg)
91
Stale
Primary
Database Oplog
Client
Secondary
Database
Insert A
C
A
Insert
B
Insert B
A
C
Insert C
Oplog
Insert A
![Page 92: KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB](https://reader034.fdocument.pub/reader034/viewer/2022052619/55614fbfd8b42a857d8b4e66/html5/thumbnails/92.jpg)
92
Stale
Primary
Database Oplog
Client
Secondary
Database
Insert A
A
A
Update
B
Insert B
A
C
Insert C
Update A
Oplog
Insert A
![Page 93: KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB](https://reader034.fdocument.pub/reader034/viewer/2022052619/55614fbfd8b42a857d8b4e66/html5/thumbnails/93.jpg)
93
Stale
Primary
Database
Client
Secondary
Database
C
A
Update
B
A
C
Oplog
Insert A
Oplog
Insert A
Insert B
Insert C
Update A
Update C
![Page 94: KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB](https://reader034.fdocument.pub/reader034/viewer/2022052619/55614fbfd8b42a857d8b4e66/html5/thumbnails/94.jpg)
94
Stale
Primary
Database
Client
Secondary
Database
D
A
Insert
B
A
C
Oplog
Insert A
D
Insert B
Insert C
Update A
Update C
Insert D
Insert A
![Page 95: KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB](https://reader034.fdocument.pub/reader034/viewer/2022052619/55614fbfd8b42a857d8b4e66/html5/thumbnails/95.jpg)
95
Stale
Primary
Database
Client
Secondary
Database
A
B
A
C
Oplog
Insert A
D
Insert B
Insert C
Update A
Update C
Insert D
Check Oplog
[Inset A]
not found !!
Insert A
![Page 96: KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB](https://reader034.fdocument.pub/reader034/viewer/2022052619/55614fbfd8b42a857d8b4e66/html5/thumbnails/96.jpg)
96
Stale
Primary
Database
Client
Recovering
Database
A
B
A
C
Oplog
Insert A
D
Insert B
Insert C
Update A
Update C
Insert D
Check Oplog
[Inset A]
not found !!
It cannot get
infomation about
[Insert B].
So cannot sync !!
It’s called STALE Insert A
![Page 97: KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB](https://reader034.fdocument.pub/reader034/viewer/2022052619/55614fbfd8b42a857d8b4e66/html5/thumbnails/97.jpg)
97
Stale
We can specify the oplog size as one of the command line option
Only at the first time per the dbpath
that is also specified as a command line.
Also we cannot change the oplog size
without clearing the dbpath.
Be careful !
We have to understand the importance of adjusting oplog size
![Page 98: KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB](https://reader034.fdocument.pub/reader034/viewer/2022052619/55614fbfd8b42a857d8b4e66/html5/thumbnails/98.jpg)
98
Replication (Join as a new node)
![Page 99: KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB](https://reader034.fdocument.pub/reader034/viewer/2022052619/55614fbfd8b42a857d8b4e66/html5/thumbnails/99.jpg)
99
InitialSync
Primary
Database
Client
A
B
C
D
Oplog
Insert C
Update A
Update C
Insert D
mongod
![Page 100: KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB](https://reader034.fdocument.pub/reader034/viewer/2022052619/55614fbfd8b42a857d8b4e66/html5/thumbnails/100.jpg)
100
InitialSync
Primary
Database
Client
Startup
Database
A
B
C
Oplog
D
Oplog
Insert C
Update A
Update C
Insert D
mongod mongod
![Page 101: KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB](https://reader034.fdocument.pub/reader034/viewer/2022052619/55614fbfd8b42a857d8b4e66/html5/thumbnails/101.jpg)
101
InitialSync
Primary
Database
Client
Recovering
Database
A
B
C
Oplog
D
Oplog
Insert C
Update A
Update C
Insert D
Get last Oplog
Insert D
![Page 102: KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB](https://reader034.fdocument.pub/reader034/viewer/2022052619/55614fbfd8b42a857d8b4e66/html5/thumbnails/102.jpg)
102
InitialSync
Primary
Database
Client
Recovering
Database
A
B
C
Oplog
D
Oplog
Insert C
Update A
Update C
Insert D
Cloning DB
Insert D
A
B
C
D
![Page 103: KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB](https://reader034.fdocument.pub/reader034/viewer/2022052619/55614fbfd8b42a857d8b4e66/html5/thumbnails/103.jpg)
103
InitialSync
Primary
Database
Client
Recovering
Database
A
B
C
Oplog
D
Oplog
Insert C
Update A
Update C
Insert D
Cloning DB
Insert D A
A
B
C
D
![Page 104: KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB](https://reader034.fdocument.pub/reader034/viewer/2022052619/55614fbfd8b42a857d8b4e66/html5/thumbnails/104.jpg)
104
InitialSync
Primary
Database
Client
Recovering
Database
A
B
C
Oplog
D
Oplog
Insert C
Update A
Update C
Insert D
Cloning DB
Insert D A
A
B
C
D E
Insert
E Insert E
B
![Page 105: KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB](https://reader034.fdocument.pub/reader034/viewer/2022052619/55614fbfd8b42a857d8b4e66/html5/thumbnails/105.jpg)
105
InitialSync
Primary
Database
Client
Recovering
Database
A
B
C
Oplog
D
Oplog
Update A
Update C
Insert D
Cloning DB complete
Insert D
A
B
C
D
B
Update
E
Insert E
Update B
![Page 106: KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB](https://reader034.fdocument.pub/reader034/viewer/2022052619/55614fbfd8b42a857d8b4e66/html5/thumbnails/106.jpg)
106
InitialSync
Primary
Database
Client
Recovering
Database
A
B
C
Oplog
D
Oplog
Update C
Insert D
Check Oplog
Insert D
A
B
C
D
E
Insert E
Update B
![Page 107: KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB](https://reader034.fdocument.pub/reader034/viewer/2022052619/55614fbfd8b42a857d8b4e66/html5/thumbnails/107.jpg)
107
InitialSync
Primary
Database
Client
Secondary
Database
A
B
C
Oplog
D
Oplog
Update C
Insert D
Sync
Insert D
E
Insert E
Update B
Insert E
Update B
A
B
C
D
E
![Page 108: KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB](https://reader034.fdocument.pub/reader034/viewer/2022052619/55614fbfd8b42a857d8b4e66/html5/thumbnails/108.jpg)
108
Additional infomation
Secondary will try to sync from other Secondaries
when it cannot reach the Primary or
might be stale against the Primary.
There is a bit of chance that sync problem not occured if the
secondary has old Oplog or larger Oplog space than Primary
From source code. ( I’ve never examed these... )
![Page 109: KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB](https://reader034.fdocument.pub/reader034/viewer/2022052619/55614fbfd8b42a857d8b4e66/html5/thumbnails/109.jpg)
109
Sync from another secondary
Primary
Database
Client
Secondary
Database
A
B
A
C
Oplog
Insert A
D
Insert B
Insert C
Update A
Update C
Insert D
Insert A
Secondary
Database
A
B
C
D
Insert B
Insert C
Update A
Update C
Insert D
Insert A
![Page 110: KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB](https://reader034.fdocument.pub/reader034/viewer/2022052619/55614fbfd8b42a857d8b4e66/html5/thumbnails/110.jpg)
110
Sync from another secondary
Primary
Database
Client
Secondary
Database
A
B
A
C
Oplog
Insert A
D
Insert B
Insert C
Update A
Update C
Insert D
Insert A
Secondary
Database
A
B
C
D
Insert B
Insert C
Update A
Update C
Insert D
Insert A
Check Oplog
[Inset A]
not found !!
![Page 111: KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB](https://reader034.fdocument.pub/reader034/viewer/2022052619/55614fbfd8b42a857d8b4e66/html5/thumbnails/111.jpg)
111
Sync from another secondary
Primary
Database
Client
Secondary
Database
A
B
A
C
Oplog
Insert A
D
Insert B
Insert C
Update A
Update C
Insert D
Insert A
Secondary
Database
A
B
C
D
Insert B
Insert C
Update A
Update C
Insert D
Insert A
Check Oplog
But found at the other secondary
So it’s able to sync
![Page 112: KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB](https://reader034.fdocument.pub/reader034/viewer/2022052619/55614fbfd8b42a857d8b4e66/html5/thumbnails/112.jpg)
112
Sync from the other secondary
Primary
Database
Client
Secondary
A
B
C
D
Insert C
Update A
Update C
Insert D
Secondary
Database
A
B
C
D
Insert B
Insert C
Update A
Update C
Insert D
Insert A
Sync
But found at the other secondary
So it’s able to sync
Database
A
B
C
D
Insert C
Update A
Update C
Insert D
Insert B
Insert A
Insert B
Insert A
![Page 113: KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB](https://reader034.fdocument.pub/reader034/viewer/2022052619/55614fbfd8b42a857d8b4e66/html5/thumbnails/113.jpg)
113
That’s all about sync
![Page 114: KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB](https://reader034.fdocument.pub/reader034/viewer/2022052619/55614fbfd8b42a857d8b4e66/html5/thumbnails/114.jpg)
114
Others...
![Page 115: KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB](https://reader034.fdocument.pub/reader034/viewer/2022052619/55614fbfd8b42a857d8b4e66/html5/thumbnails/115.jpg)
115
Disk space
![Page 116: KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB](https://reader034.fdocument.pub/reader034/viewer/2022052619/55614fbfd8b42a857d8b4e66/html5/thumbnails/116.jpg)
116
Disk space
Data fragment into any DB files sparsely...
We met the unfavorable circumstance in our DBs
This circumstance appears at some of our collections
around 3 months after we launched the services
db.ourcol.storageSize() = 16200727264 (15GB)
db.ourcol.totalSize() = 16200809184
db.ourcol.totalIndexSize() = 81920
db.outcol.dataSize() = 2032300 (2MB)
What’s happen to them !!
![Page 117: KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB](https://reader034.fdocument.pub/reader034/viewer/2022052619/55614fbfd8b42a857d8b4e66/html5/thumbnails/117.jpg)
117
Disk space
Data fragment into any DB files sparsely...
It’s seems like to be caused by the specific operation
that insert , update and delete over and over.
Anyway we have to shrink the using disk space regularly
just like PostgreSQL’s vacume.
But how to do it ?
![Page 118: KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB](https://reader034.fdocument.pub/reader034/viewer/2022052619/55614fbfd8b42a857d8b4e66/html5/thumbnails/118.jpg)
118
Disk space
Shrink the using disk spaces
MongoDB offers some functions for this case.
But couldn’t use in our case !
repairdatabase:
Only runable on the Primary.
It needs long time and BLOCK all operations !!
compact:
Only runable on the Secondary.
Zero-fill the blank space instead of shrink disk spaces.
So cannot shrink...
![Page 119: KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB](https://reader034.fdocument.pub/reader034/viewer/2022052619/55614fbfd8b42a857d8b4e66/html5/thumbnails/119.jpg)
119
Disk space
Our measurements
For temporary collection:
To issue drop-command regularly.
For other collections:
1. Get rid of one secondary from the ReplSet.
2. Shut down this.
3. Remove all DB files.
4. Join to the ReplSet.
5. Do these operations one after another.
6. Step down the Primary. (Change Primary node)
7. At last, do 1 – 4 operations on prior Primary.
![Page 120: KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB](https://reader034.fdocument.pub/reader034/viewer/2022052619/55614fbfd8b42a857d8b4e66/html5/thumbnails/120.jpg)
120
PHP client
![Page 121: KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB](https://reader034.fdocument.pub/reader034/viewer/2022052619/55614fbfd8b42a857d8b4e66/html5/thumbnails/121.jpg)
121
PHP client
We tried 1.4.4 and 1.2.2
1.4.4:
There is some critical bugs around connection pool.
We struggled to invalidate the broken connection.
I think, you should use 1.2.X instead of 1.4.X
1.2.2:
It seems like to be fixed around connection pool.
But there are 2 critical bugs !
– Socket handle leak
– Useless sleep
However, This version is relatively stable
as long as to fix these bugs
![Page 122: KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB](https://reader034.fdocument.pub/reader034/viewer/2022052619/55614fbfd8b42a857d8b4e66/html5/thumbnails/122.jpg)
122
PHP client
We tried 1.4.4 and 1.2.2
https://github.com/crumbjp/Personal
- mongo1.2.2.non-wait.patch
- mongo1.2.2.sock-leak.patch
![Page 123: KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB](https://reader034.fdocument.pub/reader034/viewer/2022052619/55614fbfd8b42a857d8b4e66/html5/thumbnails/123.jpg)
123
PHP client
![Page 124: KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB](https://reader034.fdocument.pub/reader034/viewer/2022052619/55614fbfd8b42a857d8b4e66/html5/thumbnails/124.jpg)
124
Closing
![Page 125: KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB](https://reader034.fdocument.pub/reader034/viewer/2022052619/55614fbfd8b42a857d8b4e66/html5/thumbnails/125.jpg)
125
Closing
What’s MongoDB ?
It has very good READ performance.
We can use mongo instead of memcached.
if we can allow the limited write performance.
Die hard !
MongoDB have high availability even if under a severe stress..
Can use easilly without deep consideration
We can manage to do anything after getting start to use.
Let’s forget any awkward trivial things that have bothered us.
How to treat the huge data ?
How to put in the cache system ?
How to keep the availablity ?
And so on ....
![Page 126: KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB](https://reader034.fdocument.pub/reader034/viewer/2022052619/55614fbfd8b42a857d8b4e66/html5/thumbnails/126.jpg)
126
Closing
Keep in mind
Sharding is challenging...
It’s last resort !
It’s hard to operate. In particular, to maintain config-servers.
[Mongos] is also difficult to keep alive.
I want the way to failover Mongos.
Mongo is able to run on the poor environment but...
You should ONLY put aside the large diskspace
Huge write is sensitive
Adjust the oplog size carefully
Indexing function has been unfinished
Cannot apply index online
![Page 127: KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB](https://reader034.fdocument.pub/reader034/viewer/2022052619/55614fbfd8b42a857d8b4e66/html5/thumbnails/127.jpg)
127
All right, Have fun !!
![Page 128: KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB](https://reader034.fdocument.pub/reader034/viewer/2022052619/55614fbfd8b42a857d8b4e66/html5/thumbnails/128.jpg)
128
Thank you for your listening