capacity planning for mongodb

36
Technical Director, 10gen @jonnyeight [email protected] alvinonmongodb.com Alvin Richards #MongoDBdays Capacity Planning: Choosing What to Deploy and When

Upload: alvin-john-richards

Post on 07-Nov-2014

145 views

Category:

Documents


3 download

DESCRIPTION

Deploying MongoDB can be a challenge if you don't understand how resources are used nor how to plan for the capacity of your systems. If you need to deploy, or grow, a MongoDB single instance, replica set, or tens of sharded clusters then you probably share the same challenges in trying to size that deployment. This talk will cover what resources MongoDB uses, and how to plan for their use in your deployment. Topics covered will include understanding how to model and plan capacity needs from the perspective of a new deployment, growing an existing one, and defining where the steps along scalability on your path to the top. The goal of this presentation will be to provide you with the tools needed to be successful in managing your MongoDB capacity planning tasks.

TRANSCRIPT

Page 1: Capacity Planning for MongoDB

Technical Director, 10gen

@jonnyeight [email protected] alvinonmongodb.com

Alvin Richards

#MongoDBdays

Capacity Planning: Choosing What to Deploy and When

Page 2: Capacity Planning for MongoDB

http://hci.stanford.edu/jheer/files/zoo/ex/maps/napoleon.html

But first a story…

Page 3: Capacity Planning for MongoDB

What are the consequences of not planning?

Capacity Planning: Why, What, When

Why?

Page 4: Capacity Planning for MongoDB

What are the consequences of not planning?

Capacity Planning: Why, What, When

Why?

Page 5: Capacity Planning for MongoDB

•  Availability •  Throughput •  Latency

What?

Capacity Planning: Why, What, When

Page 6: Capacity Planning for MongoDB

Before it's too late!

When?

Capacity Planning: Why, What, When

Start Launch Version 2

Page 7: Capacity Planning for MongoDB

Before it's too late!

When?

Capacity Planning: Why, What, When

Start Launch Version 2

Page 8: Capacity Planning for MongoDB

Problems

•  Capacity –  Under –  Over –  Just right?

•  Prediction Models –  User/Load –  System(s) Behavior

•  Change Velocity (reaction time) –  Data/Resource-Allocation/Provisioning

Page 9: Capacity Planning for MongoDB

Resource Usage

•  Storage –  IOPS –  Size –  Data & Loading Patterns

•  Memory –  Working Set

•  CPU –  Speed –  Cores

•  Network –  Latency –  Throughput

Page 10: Capacity Planning for MongoDB

7,200 rpm SATA ~ 75-100 IOPS

15,000 rpm SAS ~ 175-210 IOPS

Amazon EBS/Provisioned ~ 100 IOPS "up to" 2,000 IOPS

Amazon SSD 9,000 – 120,000 IOPS

Storage Capability Example IOPs

Page 11: Capacity Planning for MongoDB

7,200 rpm SATA ~ 75-100 IOPS

15,000 rpm SAS ~ 175-210 IOPS

Amazon EBS/Provisioned ~ 100 IOPS "up to" 2,000 IOPS

Amazon SSD 9,000 – 120,000 IOPS

Storage Capability Example IOPs

Intel X25-E (SLC) ~ 5,000 IOPS

Fusion IO ~ 135,000 IOPS

Violin Memory 6000 ~ 1,000,000 IOPS

Page 12: Capacity Planning for MongoDB

Storage Measuring and Monitoring

Page 13: Capacity Planning for MongoDB

Storage Measuring and Monitoring

Page 14: Capacity Planning for MongoDB

Storage Measuring and Monitoring

Page 15: Capacity Planning for MongoDB

Storage

•  Active

•  Archival

•  Loading Patterns

•  Integration (BI/DW)

Page 16: Capacity Planning for MongoDB

db.blogs.stats() {

"ns" : "test.blogs", "count" : 1338330, "size" : 46915928, "avgObjSize" : 35.05557523181876, "storageSize" : 86092032, "numExtents" : 12, "nindexes" : 2, "lastExtentSize" : 20872960, "paddingFactor" : 1, "flags" : 0, "totalIndexSize" : 99860480, "indexSizes" : { "_id_" : 55877632, "name_1" : 43982848 }, "ok" : 1

}

stats()

Size of data

Average document size

Size on Disk

Size of all indexes

Size of each index

Page 17: Capacity Planning for MongoDB

•  Sorting

•  Aggregation

•  Connections

•  Working Set –  Active Data in Memory –  Measured Over Periods

•  Ratio to Storage

Memory

Page 18: Capacity Planning for MongoDB

•  New in 2.4 – db.serverStatus( { workingSet: 1 } )

Memory Measuring and Monitoring

Page 19: Capacity Planning for MongoDB

MOPs

PFs

Memory and Storage MOPS: MongoDB Ops/Sec

Page 20: Capacity Planning for MongoDB

% Disk Util

MOPS

Memory and Storage

Page 21: Capacity Planning for MongoDB

Estimating Sample Use Case •  User log on

•  Read "user" collection based on supplied credentials •  Update "last seen" and "ip" on "user" collection •  Insert into "events" collection •  Update "activity" collection for time series metrics

Page 22: Capacity Planning for MongoDB

Estimating Sample Use Case – Worst Case

Index Read(s)

Index Write(s)

Journal Write

Data Read(s)

Data Write(s)

OpLog Write(s)

Read "user" collection based on supplied credentials

4k 4k

Update "last seen" and "ip" on "user" collection

Maybe* Maybe** sizeof(bson) 4k 4k 4k

Insert into "events" collection

4k per Index

sizeof(bson) 4k 4k

Upsert "activity" collection for time series metrics

4k 4k per index

sizeof(bson)

4k 4k 4k

* Only if page is faulted out by the O/S before this operation executes ** if indexes exists on attributes updated, index update will also occur

Page 23: Capacity Planning for MongoDB

Estimating Sample Use Case •  User log on

•  Read "user" collection based on supplied credentials •  8k Read

•  Update "last seen" and "ip" on "user" collection •  4k Read, 4k Write (single index), 4k Write OpLog

•  Insert into "events" collection •  8k Write (single index), 4k Write OpLog

•  Update "activity" collection for time series metrics •  8k Read, 8k Write (single index), 4k Write OpLog

•  System load •  20k Read, 36k Write

Page 24: Capacity Planning for MongoDB

CPU

•  Non-indexed Data

•  Sorting

•  Aggregation –  Map/Reduce –  Framework

•  Data –  Fields –  Nesting –  Arrays/Embedded-Docs

Page 25: Capacity Planning for MongoDB

MOPs

CPU

Page 26: Capacity Planning for MongoDB

MOPs

CPU %

CPU

Page 27: Capacity Planning for MongoDB

•  Non-indexed Data

•  Sorting

•  Aggregation –  Map/Reduce –  Framework

•  Data –  Fields –  Nesting –  Arrays/Embedded-Docs

CPU

Page 28: Capacity Planning for MongoDB

•  Latency –  WriteConcern –  ReadPreference –  Batching –  Documents (and Collections)

•  Throughput –  Update / Write Patterns –  Reads / Queries –  SAN / NAS –  Virtualization

Network

Page 29: Capacity Planning for MongoDB

All of these use the same resources:

•  Single Instance

•  Multiple Instances (Replica Set)

•  Cluster (Sharding)

•  Data Centers

Deployment Types

Page 30: Capacity Planning for MongoDB

•  Storage

•  Memory

•  CPU

•  Network

•  Application Metrics

Monitoring

Page 31: Capacity Planning for MongoDB

•  MMS (MongoDB Monitoring Service)

•  MongoDB: mongotop, mongostat

•  Linux: iostat, vmstat, sar, etc

•  Windows: Perfmon

•  Load testing

Tools

Page 32: Capacity Planning for MongoDB

•  Load/Users –  Response Time/TTFB

•  System Performance –  Peak Usage –  Min Usage

Models

Page 33: Capacity Planning for MongoDB

•  Limitations –  Data Movement –  Allocation/Provisioning (servers/mem/disk)

•  Improvement –  Limit Size of Change (if you can) –  Increase Frequency –  Practice

Velocity of Change

Page 34: Capacity Planning for MongoDB

•  Repeat Testing

•  Repeat Evaluations

•  Repeat Deployment

Repeat (continuously)

Page 35: Capacity Planning for MongoDB

•  What is the working set? –  How does that equate to memory –  How much disk access will that require

•  How efficient are the queries?

•  What is the rate of data change?

•  How big are the highs and lows?

Starter Questions

Page 36: Capacity Planning for MongoDB

Technical Director, 10gen

@jonnyeight [email protected] alvinonmongodb.com

Alvin Richards

#MongoDBdays

Thank You