scale your mongodb in 5 easy steps

6
5 Steps to Scale your MongoDB 5 Steps to Scale your MongoDB

Upload: dataversity

Post on 20-Aug-2015

789 views

Category:

Entertainment & Humor


1 download

TRANSCRIPT

Page 1: Scale your MongoDB in 5 Easy Steps

5 Steps to Scale your MongoDB5 Steps to Scale your MongoDB

Page 2: Scale your MongoDB in 5 Easy Steps

1. Optimize your Queries1. Optimize your Queriesquery = db.coll.find({title:”My blog”})query.explain();

{"cursor" : "BasicCursor"cursor  :  BasicCursor ,"indexBounds" : [ ],"nscanned" : 57594,"nscannedObjects" : 57594,"n" : 3,"millis" : 108

}

db.coll.ensureIndex({title:1})

Page 3: Scale your MongoDB in 5 Easy Steps

2. Know your working set size2. Know your working set sizeActive

Documents +Documents + Used Indexes

RAM

Disk

Page 4: Scale your MongoDB in 5 Easy Steps

3. Tune your file system3. Tune your file system

• EXT3 == badEXT3 bad– Slow file allocation & initialization

EXT4 / XFS == d• EXT4 / XFS == good• Access time tracking == bad

– noatime, nodiratime

Page 5: Scale your MongoDB in 5 Easy Steps

4. Choose the right disks4. Choose the right disksSingle Disk

~200 seeks / second

RAID 0

~200 seeks / second ~200 seeks / second ~200 seeks / second

RAID 10

~400 seeks / second ~400 seeks / second ~400 seeks / second

Page 6: Scale your MongoDB in 5 Easy Steps

5. Sharding for MongoSMongoS

gwrites & RAM

Sh d 1 Sh d 2 Sh d 3 Sh d 4Shard 10..10

Shard 210..20

Shard 320..30

Shard 430..40

Primary

Secondary

Primary

Secondary

Primary

Secondary

Primary

Secondary

Secondary

y

Secondary

y

Secondary

y

Secondary

y