scaling crittercism to 30,000 requests per second and beyond with mongodb

196
Scaling to 30,000 Requests Per Second and Beyond with MongoDB Mike Chesnut Director of Operations Engineering Crittercism

Upload: mongodb

Post on 23-Jun-2015

1.606 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

Scaling to 30,000 Requests Per Secondand Beyond

with MongoDB

Mike ChesnutDirector of Operations Engineering

Crittercism

Page 2: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

Scaling to 30,000 Requests Per Secondand Beyond

with MongoDB

Mike ChesnutDirector of Operations Engineering

Crittercism

40,000

Page 3: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

How a Startup Gets Started

Page 4: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

● Pick something and go with it

How a Startup Gets Started

Page 5: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

● Pick something and go with it● Make mistakes along the way

How a Startup Gets Started

Page 6: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

● Pick something and go with it● Make mistakes along the way● Correct the mistakes you can

How a Startup Gets Started

Page 7: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

● Pick something and go with it● Make mistakes along the way● Correct the mistakes you can● Work around the ones you can’t

How a Startup Gets Started

Page 8: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

What I’ll Talk About

Page 9: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

What I’ll Talk About

● Crittercism - Background and Architecture

Page 10: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

What I’ll Talk About

● Crittercism - Background and Architecture● Router (mongos) Architecture

Page 11: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

What I’ll Talk About

● Crittercism - Background and Architecture● Router (mongos) Architecture● Sharding Considerations

Page 12: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

What I’ll Talk About

● Crittercism - Background and Architecture● Router (mongos) Architecture● Sharding Considerations● The Balancing Act

Page 13: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

What I’ll Talk About

● Crittercism - Background and Architecture● Router (mongos) Architecture● Sharding Considerations● The Balancing Act● Q&A

Page 14: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

Critter-What?

Page 15: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

Critter-What?

A Brief History...

Page 16: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

Critter-What?

Our Founders(Rob, Andrew, Jeeyun)

Page 17: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

Critter-What?

Our Founders(Rob, Andrew, Jeeyun)

Let’s make a mobile app!It’ll be awesome!

Page 18: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

Critter-What?

(Unnamed Dating App)

Page 19: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

Critter-What?

Page 20: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

Critter-What?

Page 21: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

Critter-What?

Our Founders(Rob, Andrew, Jeeyun)

Our app isn’t so awesomeafter all...

Page 22: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

Critter-What?

Page 23: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

Critter-What?

Page 24: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

Critter-What?

Page 25: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

Critter-What?

Page 26: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

Critter-What?

Page 27: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

Critter-What?

Page 28: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

Critter-What?

Page 29: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

Critter-What?

Page 30: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

Architecture

Page 31: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

Architecture

Page 32: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

Architecture

API

Page 33: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

Architecture

APIFeedback

Page 34: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

Architecture

APIFeedback

Crashes

Page 35: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

Architecture

APIFeedback

App Loads

Crashes

Page 36: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

Architecture

APIFeedback

App Loads

Crashes

HandledExceptions

Page 37: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

Architecture

APIFeedback

App Loads

Crashes

HandledExceptions

Page 38: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

Architecture

API

App Loads

Crashes

HandledExceptions

Page 39: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

Architecture

APIApp Loads

Crashes

HandledExceptions

Page 40: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

Architecture

API

Crashes

HandledExceptions

App Loads

batch

Page 41: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

Architecture

API

Crashes

HandledExceptions

Metadata

App Loads

batch

Page 42: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

Architecture

DynamoDB

API

Crashes

HandledExceptions

Metadata

App Loads

batch

Page 43: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

Architecture

DynamoDB

API

Crashes

HandledExceptions

Metadata

App Loads

batch

Page 44: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

Architecture

DynamoDB

API

API

Crashes

HandledExceptions

Metadata

PerformanceData

Geo Data

App Loads

batch

Page 45: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

Architecture

DynamoDB

API

API

Crashes

HandledExceptions

Metadata

PerformanceData

Geo Data

40,000 req/s

App Loads

batch

Page 46: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

Growth

Page 47: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

Router Architecture

Page 48: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

Router Architecture

mongodserver

mongodserver

mongodserver

replica set

mongodserver

mongodserver

mongodserver

replica set

mongodserver

mongodserver

mongodserver

replica set

MongoDB Cluster

Page 49: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

Router Architecture

mongodserver

mongodserver

mongodserver

replica set

mongodserver

mongodserver

mongodserver

replica set

mongodserver

mongodserver

mongodserver

replica set

clientprocess

application server

clientprocess

application server

Client Application(s) MongoDB Cluster

Page 50: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

Router Architecture

mongodserver

mongodserver

mongodserver

replica set

mongodserver

mongodserver

mongodserver

replica set

mongodserver

mongodserver

mongodserver

replica setmongos

clientprocess

application server

mongos

clientprocess

application server

Client Application(s) MongoDB Cluster

Page 51: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

Router Architecture

mongodserver

mongodserver

mongodserver

replica set

mongodserver

mongodserver

mongodserver

replica set

mongodserver

mongodserver

mongodserver

replica setmongos

clientprocess

application server

mongos

clientprocess

application server

Client Application(s) MongoDB Cluster

Page 52: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

Router Architecture

mongodserver

mongodserver

mongodserver

replica set

mongodserver

mongodserver

mongodserver

replica set

mongodserver

mongodserver

mongodserver

replica setmongos

clientprocess

application server

mongos

clientprocess

application server

Client Application(s) MongoDB Clustermongodserver

mongodserver

configserver

config servers

Page 53: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

Router Architecture

mongodserver

mongodserver

mongodserver

replica set

mongodserver

mongodserver

mongodserver

replica set

mongodserver

mongodserver

mongodserver

replica setmongos

clientprocess

application server

mongos

clientprocess

application server

Client Application(s) MongoDB Clustermongodserver

mongodserver

configserver

config servers

Page 54: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

Router Architecture

mongodserver

mongodserver

mongodserver

replica set

mongodserver

mongodserver

mongodserver

replica set

mongodserver

mongodserver

mongodserver

replica setmongos

clientprocess

application server

mongos

clientprocess

application server

Client Application(s) MongoDB Clustermongodserver

mongodserver

configserver

config servers

Page 55: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

Router Architecture

RS

RS

RS

conf

ms

app

ms

app

Page 56: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

Router Architecture

RS

RS

RS

confms

app

ms

app

ms

app

ms

app

ms

app

ms

app

ms

app

ms

app

ms

app

ms

app

ms

appms

app

ms

app

ms

app

ms

app

ms

app

ms

app

ms

app

ms

app

ms

app

ms

app

ms

app

Page 57: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

Router Architecture

RS

RS

RS

confms

app

ms

app

ms

app

ms

app

ms

app

ms

app

ms

app

ms

app

ms

app

ms

app

ms

appms

app

ms

app

ms

app

ms

app

ms

app

ms

app

ms

app

ms

app

ms

app

ms

app

ms

app

.

.

.

Page 58: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

Single mongos per client problems we encountered:

Router Architecture

Page 59: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

Router Architecture

Single mongos per client problems we encountered:● thousands of connections to config servers

Page 60: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

Router Architecture

Single mongos per client problems we encountered:● thousands of connections to config servers● config server CPU load

Page 61: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

Router Architecture

Single mongos per client problems we encountered:● thousands of connections to config servers● config server CPU load● configdb propagation delays

Page 62: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

Router Architecture

RS

RS

RS

confms

app

ms

app

ms

app

ms

app

ms

app

ms

app

ms

app

ms

app

ms

app

ms

app

ms

appms

app

ms

app

ms

app

ms

app

ms

app

ms

app

ms

app

ms

app

ms

app

ms

app

ms

app

.

.

.

We went from this...

Page 63: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

Router Architecture

RS

RS

RS

confms

app

ms

app

ms

app

ms

app

ms

app

ms

app

ms

app

ms

app

ms

app

ms

appms

appms

app

ms

app

ms

app

ms

app

ms

app

ms

app

ms

app

ms

app

ms

app

ms

app msapp

.

.

.

.

.

.

To this.

Page 64: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

Router Architecture

mongodserver

mongodserver

mongodserver

replica set

mongodserver

mongodserver

mongodserver

replica set

mongodserver

mongodserver

mongodserver

replica setmongos

clientprocess

application server

mongos

clientprocess

application server

Client Application(s) MongoDB Cluster

Page 65: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

Router Architecture

mongodserver

mongodserver

mongodserver

replica set

mongodserver

mongodserver

mongodserver

replica set

mongodserver

mongodserver

mongodserver

replica set

mongos

clientprocess

application server

mongos

clientprocess

application server

Client Application(s) MongoDB ClusterRouter Tier

Page 66: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

Router Architecture

Separate mongos tier advantages:

Page 67: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

Router Architecture

Separate mongos tier advantages:● greatly reduced number of connections to each mongod

Page 68: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

Router Architecture

Separate mongos tier advantages:● greatly reduced number of connections to each mongod● far fewer hosts talking to the config servers

Page 69: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

Router Architecture

Separate mongos tier advantages:● greatly reduced number of connections to each mongod● far fewer hosts talking to the config servers● much faster configdb propagation

Page 70: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

Router Architecture

Separate mongos tier advantages:● greatly reduced number of connections to each mongod● far fewer hosts talking to the config servers● much faster configdb propagation

Disadvantages:

Page 71: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

Router Architecture

Separate mongos tier advantages:● greatly reduced number of connections to each mongod● far fewer hosts talking to the config servers● much faster configdb propagation

Disadvantages:● additional network hop

Page 72: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

Router Architecture

Separate mongos tier advantages:● greatly reduced number of connections to each mongod● far fewer hosts talking to the config servers● much faster configdb propagation

Disadvantages:● additional network hop● host failure has a larger effect

Page 73: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

Router Architecture

RS

RS

RS

confms

app

ms

app

ms

app

ms

app

ms

app

ms

app

ms

app

ms

app

ms

app

ms

app

ms

appms

app

ms

app

ms

app

ms

app

ms

app

ms

app

ms

app

ms

app

ms

app

ms

app

ms

app

.

.

.

mongos-per-host failure:

Page 74: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

Router Architecture

RS

RS

RS

confms

app

ms

app

ms

app

ms

app

ms

app

ms

app

ms

app

ms

app

ms

app

ms

app

ms

appms

app

ms

app

ms

app

ms

app

ms

app

ms

app

ms

app

ms

app

ms

app

ms

app

ms

app

.

.

.

mongos-per-host failure:

Page 75: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

Router Architecture

RS

RS

RS

confms

app

ms

app

ms

app

ms

app

ms

app

ms

app

ms

app

ms

app

ms

app

ms

app

ms

appms

app

ms

app

ms

app

ms

app

ms

app

ms

app

ms

app

ms

app

ms

app

ms

app

ms

app

.

.

.

mongos-per-host failure:

Page 76: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

Router Architecture

RS

RS

RS

confms

app

ms

app

ms

app

ms

app

ms

app

ms

app

ms

app

ms

app

ms

app

ms

appms

appms

app

ms

app

ms

app

ms

app

ms

app

ms

app

ms

app

ms

app

ms

app

ms

app msapp

.

.

.

.

.

.

Separate mongos tier failure:

Page 77: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

Router Architecture

RS

RS

RS

confms

app

ms

app

ms

app

ms

app

ms

app

ms

app

ms

app

ms

app

ms

app

ms

appms

appms

app

ms

app

ms

app

ms

app

ms

app

ms

app

ms

app

ms

app

ms

app

ms

app msapp

.

.

.

.

.

.

Separate mongos tier failure:

Page 78: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

Router Architecture

RS

RS

RS

confms

app

ms

app

ms

app

ms

app

ms

app

ms

app

ms

app

ms

app

ms

app

ms

appms

appms

app

ms

app

ms

app

ms

app

ms

app

ms

app

ms

app

ms

app

ms

app

ms

app msapp

.

.

.

.

.

.

Separate mongos tier failure:

Page 79: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

Router Architecture

RS

RS

RS

confms

app

ms

app

ms

app

ms

app

ms

app

ms

app

ms

app

ms

app

ms

app

ms

appms

appms

app

ms

app

ms

app

ms

app

ms

app

ms

app

ms

app

ms

app

ms

app

ms

app msapp

.

.

.

.

.

.

So increase the number of mongos routers:

Page 80: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

Router Architecture

RS

RS

RS

confms

app

ms

app

ms

app

ms

app

ms

app

ms

app

ms

app

ms

app

ms

app

ms

appms

appms

app

ms

app

ms

app

ms

app

ms

app

ms

app

ms

app

ms

app

ms

app

ms

appms

app

.

.

.

.

.

.

ms

ms

So increase the number of mongos routers:

Page 81: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

Router Architecture - Evolve!

Page 82: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

Router Architecture - Evolve!

mongodserver

mongodserver

mongodserver

replica set

mongodserver

mongodserver

mongodserver

replica set

mongodserver

mongodserver

mongodserver

replica setmongos

clientprocess

application server

mongos

clientprocess

application server

Client Application(s) MongoDB ClusterMaybe at first,doing themongos-per-hostarchitectureis fine.

Page 83: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

Maybe at first,doing themongos-per-hostarchitectureis fine.

And it will probablyremain finefor quite a while.

Router Architecture - Evolve!

mongodserver

mongodserver

mongodserver

replica set

mongodserver

mongodserver

mongodserver

replica set

mongodserver

mongodserver

mongodserver

replica setmongos

clientprocess

application server

mongos

clientprocess

application server

Client Application(s) MongoDB Cluster

Page 84: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

Router Architecture - Evolve!

mongodserver

mongodserver

mongodserver

replica set

mongodserver

mongodserver

mongodserver

replica set

mongodserver

mongodserver

mongodserver

replica set

mongos

clientprocess

application server

mongos

clientprocess

application server

Client Application(s) MongoDB ClusterRouter TierThis is an areawhere you canand should bewilling to adaptas you go(and as needed).

Page 85: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

Sharding Considerations

Page 86: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

Pick something you want to live with.

Sharding Considerations

Page 87: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

Sharding Considerations

Page 88: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

Sharding Considerations

Page 89: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

Sharding Considerations

Page 90: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

Sharding Considerations

Page 91: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

Sharding Considerations

Page 92: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

Sharding Considerations

Page 93: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

Sharding Considerations

Page 94: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

Sharding Considerations

Page 95: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

Sharding Considerations

Page 96: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

Sharding Considerations

Page 97: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

Sharding Considerations

Page 98: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

Sharding Considerations

Page 99: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

Sharding Considerations

Page 100: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

Sharding Considerations

Page 101: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

Sharding Considerations

Page 102: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

Sharding Considerations

Page 103: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

Sharding Considerations

Page 104: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

Sharding Considerations

Page 105: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

Sharding Considerations

Page 106: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

Sharding Considerations

Page 107: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

Sharding Considerations

Page 108: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

Sharding Considerations

Page 109: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

Sharding Considerations

Page 110: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

Sharding Considerations

Page 111: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

Sharding Considerations

Page 112: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

Sharding Considerations

Page 113: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

Sharding Considerations

Page 114: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

Sharding Considerations

Page 115: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

Sharding Considerations

Page 116: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

Sharding Considerations

Page 117: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

Sharding Considerations

Page 118: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

What could we have done differently?

Sharding Considerations

Page 119: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

Sharding Considerations

Page 120: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

Sharding Considerations

Page 121: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

Sharding Considerations

Page 122: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

Sharding Considerations

Page 123: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

Sharding Considerations

Page 124: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

Sharding Considerations

Page 125: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

Sharding Considerations

Page 126: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

Sharding Considerations

Page 127: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

Sharding Considerations

Page 128: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

Sharding Considerations

Page 129: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

Sharding Considerations

Page 130: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

Sharding Considerations

Page 131: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

Sharding Considerations

Page 132: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

Sharding Considerations

Page 133: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

Sharding Considerations

Page 134: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

Sharding Considerations

Page 135: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

Sharding Considerations

Page 136: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

Sharding Considerations

Page 137: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

Sharding Considerations

Page 138: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

Sharding Considerations

Page 139: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

The Balancing Act

Page 140: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

The Balancing Act

Why wouldn’t you run the balancer in the first place?

Page 141: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

The Balancing Act

Why wouldn’t you run the balancer in the first place?● great question

Page 142: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

The Balancing Act

Why wouldn’t you run the balancer in the first place?● great question● for us, it’s because we deleted some old data at one point, and left

a bunch of holes

Page 143: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

The Balancing Act

Why wouldn’t you run the balancer in the first place?● great question● for us, it’s because we deleted some old data at one point, and left

a bunch of holes○ we turned it off while deleting this data

Page 144: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

The Balancing Act

Why wouldn’t you run the balancer in the first place?● great question● for us, it’s because we deleted some old data at one point, and left

a bunch of holes○ we turned it off while deleting this data○ and then were unable to turn it back on

Page 145: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

The Balancing Act

Why wouldn’t you run the balancer in the first place?● great question● for us, it’s because we deleted some old data at one point, and left

a bunch of holes○ we turned it off while deleting this data○ and then were unable to turn it back on

● but maybe you start without it

Page 146: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

The Balancing Act

Why wouldn’t you run the balancer in the first place?● great question● for us, it’s because we deleted some old data at one point, and left

a bunch of holes○ we turned it off while deleting this data○ and then were unable to turn it back on

● but maybe you start without it● or maybe you need to turn it off for maintenance and forget to turn

it back on

Page 147: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

The Balancing Act

Why wouldn’t you run the balancer in the first place?● great question● for us, it’s because we deleted some old data at one point, and left

a bunch of holes○ we turned it off while deleting this data○ and then were unable to turn it back on

● but maybe you start without it● or maybe you need to turn it off for maintenance and forget to turn

it back on

Obviously, don’t do this. But if you do, here’s what happens...

Page 148: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

The Balancing Act

Fresh, new, empty cluster… But no balancer running.

Page 149: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

The Balancing Act

Page 150: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

The Balancing Act

Page 151: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

The Balancing Act

Page 152: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

The Balancing Act

Page 153: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

The Balancing Act

Page 154: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

The Balancing Act

Page 155: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

The Balancing Act

Page 156: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

The Balancing Act

Page 157: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

The Balancing Act

Page 158: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

The Balancing Act

Page 159: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

The Balancing Act

Page 160: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

The Balancing Act

Page 161: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

The Balancing Act

Page 162: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

The Balancing Act

Page 163: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

The Balancing Act

Page 164: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

The Balancing Act

Page 165: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

The Balancing Act

Page 166: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

The Balancing Act

Page 167: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

The Balancing Act

Page 168: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

The Balancing Act

Now we’re pretty full, so let’s add another shard...

Page 169: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

The Balancing Act

Page 170: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

The Balancing Act

And keep inserting...

Page 171: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

The Balancing Act

Page 172: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

The Balancing Act

Page 173: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

The Balancing Act

Page 174: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

The Balancing Act

Page 175: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

The Balancing Act

Suddenly we find ourselves with a very unbalanced cluster.

Page 176: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

The Balancing Act

But if we enable the balancer, it will DoS the 5th shard!

Page 177: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

The Balancing Act

The approximate effect looks something like this:

Page 178: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

The Balancing Act

The approximate effect looks something like this:

Page 179: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

The Balancing Act

The approximate effect looks something like this:

Page 180: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

The Balancing Act

The approximate effect looks something like this:

Page 181: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

The Balancing Act

The approximate effect looks something like this:

Page 182: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

The Balancing Act

The approximate effect looks something like this:

Page 183: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

The Balancing Act

The approximate effect looks something like this:

Page 184: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

So what can we do?

The Balancing Act

Page 185: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

So what can we do?

1. add IOPS

The Balancing Act

Page 186: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

So what can we do?

1. add IOPS2. make sure your config servers have plenty of CPU (and IOPS)

The Balancing Act

Page 187: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

So what can we do?

1. add IOPS2. make sure your config servers have plenty of CPU (and IOPS)3. slowly move chunks manually

The Balancing Act

Page 188: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

So what can we do?

1. add IOPS2. make sure your config servers have plenty of CPU (and IOPS)3. slowly move chunks manually4. approach a balanced state

The Balancing Act

Page 189: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

So what can we do?

1. add IOPS2. make sure your config servers have plenty of CPU (and IOPS)3. slowly move chunks manually4. approach a balanced state5. hold your breath

The Balancing Act

Page 190: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

So what can we do?

1. add IOPS2. make sure your config servers have plenty of CPU (and IOPS)3. slowly move chunks manually4. approach a balanced state5. hold your breath6. try re-enabling the balancer

The Balancing Act

Page 191: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

How to manually balance:

1. determine a chunk on a hot shard2. monitor effects on both the source and target shards3. move the chunk4. allow the system to settle5. repeat

The Balancing Act

Page 192: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

Conclusion here:

Run the balancer!

The Balancing Act

Page 193: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

● Design ahead of timeo “NoSQL” lets you play it by earo but some of these decisions will bite you later

● Be willing to correct past mistakeso dedicate time and resources to adaptingo learn how to live with the mistakes you can’t correct

Summary

Page 194: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

References

● MongoDB Blog post (details on shard migration):http://blog.mongodb.org/post/77278906988/crittercism-scaling-to-billions-of-requests-per-day-on

● MongoDB Webinar (details on manual chunk migrations):http://www.mongodb.com/presentations/webinar-back-basics-3-scaling-30000-requests-second-mongodb

● Documentation on mongos routers:http://docs.mongodb.org/master/core/sharded-cluster-query-routing/

● Documentation on the balancer:http://docs.mongodb.org/manual/tutorial/manage-sharded-cluster-balancer/

● Documentation on shard keys:http://docs.mongodb.org/manual/core/sharding-shard-key/

Crittercism: http://www.crittercism.com/ to learn more,and http://www.crittercism.com/careers/ if you want to help us!

Page 195: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

Q&A

Page 196: Scaling Crittercism to 30,000 Requests Per Second and Beyond with MongoDB

Thank You!