open-source, high-performance,
  document-oriented database
Why Sharding

• Vertical scaling is limited by physics and
  cost
• Hard to scale vertically in the cloud
• Can scale wider than higher
What is Sharding

• ad-hoc partitioning
• consistent hashing (Dynamo)
• range based partitioning (BigTable/PNUTS)
Overview
• Automatic partitioning and management
• range based
• Can convert from single master to sharded
  system with 0 downtime
• Almost no functionality lost over single
  master
• Fully consistent
Range Based



• collection is broken into chunks by range
Auto-sharding
                  Shards
          mongo   mongo    mongo
                                         ..
Config     mongo   mongo    mongo
Servers

mongod

mongod

mongod
                  mongos   mongos   ..


                  client
Config Servers

• 3 of them
• changes are made with 2 phase commit
• if any are down, meta data goes read only
• system is online as long as 1/3 is up
Shards


• Can be master, master/slave or replica sets
• Replica sets gives sharding + full auto-
  failover
• Regular mongod processes
mongos

• Sharding Router
• Acts just like a mongod to clients
• Can have 1 or as many as you want
• Can run on appserver so no extra network
  traffic
Writes

• Inserts : require shard key, routed
• Removes: routed and/or scattered
• Updates: routed or scattered
Queries

• By shard key: routed
• sorted by shard key: routed in order
• by non shard key: scatter gather
• sorted by non shard key: distributed merge
  sort
Operations


• split: breaking a chunk into 2
• migrate: move a chunk from 1 shard to
  another
Balancing


• distributes chunks automatically
• can look at: disk ops, cpu, data size
Multi DataCenter


• intelligent geo honing
• auto failover
Sharding Limitations


• Unique indexes not based on shard key
• current version limited to ~ 20 petabytes
After Party!

Download MongoDB
   http://www.mongodb.org

and let us know what you think
 @eliothorowitz @mongodb

Sharding with MongoDB (Eliot Horowitz)

Editor's Notes

  • #4 sharding isn’t new
  • #17 osa thai - open bar, food