Top Banner
The 5 Things You Need To Know About Scaling A. Jesse Jiryu Davis Senior Python Engineer
22

Five Things you Need to Know About Scaling

Jun 12, 2015

Download

Technology

MongoDB
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Five Things you Need to Know About Scaling

The 5 Things You Need To Know

About ScalingA. Jesse Jiryu Davis

Senior Python Engineer

Page 2: Five Things you Need to Know About Scaling

1. Indexes

Page 3: Five Things you Need to Know About Scaling

db.people.find({name: 'Jesse'}).explain()!{!! "cursor" : "BasicCursor",!! "n" : 10,!! "nscanned" : 100000,!! "millis" : 40,!}!!db.people.createIndex({name: 1});!!db.people.find({name: 'Jesse'}).explain()!{!! "cursor" : "BtreeCursor name_1",!! "n" : 10,!! "nscanned" : 10,!! "millis" : 0,!}!

1. Indexes

Page 4: Five Things you Need to Know About Scaling

db.people.find({name: 'Jesse'}).explain()!{!! "cursor" : "BasicCursor",!! "n" : 10,!! "nscanned" : 100000,!! "millis" : 40,!}!!db.people.createIndex({name: 1});!!db.people.find({name: 'Jesse'}).explain()!{!! "cursor" : "BtreeCursor name_1",!! "n" : 10,!! "nscanned" : 10,!! "millis" : 0,!}!

1. Indexes

Page 5: Five Things you Need to Know About Scaling

db.people.find({name: 'Jesse', hacks: 'Python'}).explain()!{!! "cursor" : "BtreeCursor name_1",!! "n" : 1,!! "nscanned" : 10,!! "millis" : 0,!}!!db.people.createIndex({name: 1, hacks: 1});!!db.people.find({name: 'Jesse', hacks: 'Python'}).explain()!{!! "cursor" : "BtreeCursor name_1",!! "n" : 1,!! "nscanned" : 1,!! "millis" : 0,!}!

1. Indexes

Page 6: Five Things you Need to Know About Scaling

db.people.find({name: 'Jesse', hacks: 'Python'}).explain()!{!! "cursor" : "BtreeCursor name_1",!! "n" : 1,!! "nscanned" : 10,!! "millis" : 0,!}!!db.people.createIndex({name: 1, hacks: 1});!!db.people.find({name: 'Jesse', hacks: 'Python'}).explain()!{!! "cursor" : "BtreeCursor name_1",!! "n" : 1,!! "nscanned" : 1,!! "millis" : 0,!}!

1. Indexes

Page 7: Five Things you Need to Know About Scaling

db.people.find({name: 'Jesse', hacks: 'Python'}).explain()!{!! "cursor" : "BtreeCursor name_1",!! "n" : 1,!! "nscanned" : 10,!! "millis" : 0,!}!!db.people.createIndex({name: 1, hacks: 1});!!db.people.find({name: 'Jesse', hacks: 'Python'}).explain()!{!! "cursor" : "BtreeCursor name_1",!! "n" : 1,!! "nscanned" : 1,!! "millis" : 0,!}!

1. Indexes

Page 8: Five Things you Need to Know About Scaling

db.people.find({name: 'Jesse', hacks: 'Python'}).explain()!{!! "cursor" : "BtreeCursor name_1",!! "n" : 1,!! "nscanned" : 10,!! "millis" : 0,!}!!db.people.createIndex({name: 1, hacks: 1});!!db.people.find({name: 'Jesse', hacks: 'Python'}).explain()!{!! "cursor" : "BtreeCursor name_1_hacks_1",!! "n" : 1,!! "nscanned" : 1,!! "millis" : 0,!}!!db.people.dropIndex({name: 1})!!

1. Indexes

Page 9: Five Things you Need to Know About Scaling

db.people.find({name: 'Jesse', hacks: 'Python'}).explain()!{!! "cursor" : "BtreeCursor name_1",!! "n" : 1,!! "nscanned" : 10,!! "millis" : 0,!}!!db.people.createIndex({name: 1, hacks: 1});!!db.people.find({name: 'Jesse', hacks: 'Python'}).explain()!{!! "cursor" : "BtreeCursor name_1_hacks_1",!! "n" : 1,!! "nscanned" : 1,!! "millis" : 0,!}!!db.people.dropIndex({name: 1})!!

1. Indexes

Page 10: Five Things you Need to Know About Scaling

2. File System

• ext3 is bad• ext4 and xfs are good

Page 11: Five Things you Need to Know About Scaling

• Set noatime • This goes in /etc/fstab

2. File System

Page 12: Five Things you Need to Know About Scaling

3. Working Set Size

Page 13: Five Things you Need to Know About Scaling

3. Working Set Size

Disk!

RAM!

Page 14: Five Things you Need to Know About Scaling

4. Disks

Page 15: Five Things you Need to Know About Scaling

4. DisksOption 1: Spinning disk.

100 seeks / sec

Page 16: Five Things you Need to Know About Scaling

4. DisksOption 2: Spinning disks!

Page 17: Five Things you Need to Know About Scaling

~100 seeks / second!

~100 seeks / second! ~100 seeks / second! ~100 seeks / second!

Page 18: Five Things you Need to Know About Scaling

4. DisksOption 3: SSD

Page 19: Five Things you Need to Know About Scaling

5. Shard

Page 20: Five Things you Need to Know About Scaling

Primary!

Secondary!

Secondary!

MongoS!

Primary!

Secondary!

Secondary!

Primary!

Secondary!

Secondary!

Primary!

Secondary!

Secondary!

5. Shard

Page 21: Five Things you Need to Know About Scaling

1. Indexes 2. File System 3. Working Set 4. Disks 5. Shard

Page 22: Five Things you Need to Know About Scaling

1. Indexes 2. File System 3. Working Set 4. Disks 5. Shard

The 5 Things You Need To Know About Scaling

A. Jesse Jiryu Davisbit.ly/scaling-five