27. Shard
Really is just a mongod (or replica set)
mongod
Where your data lives
28. Config Server
Mongod started with --configsvr option
config Must have 3 (or 1 in development)
Data is commited using 2 phase commit
29. mongos
Acts just like shard router / proxy
One or as many as you want
mongos
Light weight -- can run on App servers
Caches meta-data from config servers
74. Routed Request
1
1. Query arrives at Mongos
2. Mongos routes query to a
mongos single shard
2
shard shard shard
75. Routed Request
1
1. Query arrives at Mongos
2. Mongos routes query to a
mongos single shard
3. Shard returns results of
2 query
3
shard shard shard
76. Routed Request
1
1. Query arrives at Mongos
4
2. Mongos routes query to a
mongos single shard
3. Shard returns results of
2 query
4. Results returned to client
3
shard shard shard
84. Distributed Merge Sort Req.
1
1. Query arrives at Mongos
2. Mongos broadcasts query
mongos to all shards
2 2 2
shard shard shard
85. Distributed Merge Sort Req.
1
1. Query arrives at Mongos
2. Mongos broadcasts query
mongos to all shards
3. Each shard locally sorts
results
2 2 2
shard shard shard
3 3 3
86. Distributed Merge Sort Req.
1
1. Query arrives at Mongos
2. Mongos broadcasts query
mongos to all shards
3. Each shard locally sorts
results
2 2 2
4. Results returned to
mongos
4 4 4
shard shard shard
3 3 3
87. Distributed Merge Sort Req.
1
1. Query arrives at Mongos
2. Mongos broadcasts query
mongos 5 to all shards
3. Each shard locally sorts
results
2 2 2
4. Results returned to
mongos
4 4 4
5. Mongos merges sorted
results
shard shard shard
3 3 3
88. Distributed Merge Sort Req.
1
1. Query arrives at Mongos
6
2. Mongos broadcasts query
mongos 5 to all shards
3. Each shard locally sorts
results
2 2 2
4. Results returned to
mongos
4 4 4
5. Mongos merges sorted
results
shard shard shard
3 3 3 6. Combined results
returned to client
89. Queries
By Shard Key Routed db.users.find({email: “bob@10gen.com”})
Sorted by Routed in order db.users.find().sort({email:-1})
shard key
Find by non Scatter Gather db.users.find({state:”NY”})
shard key
Sorted by Distributed merge db.users.find().sort({state:1})
sort
non shard key
94. Chunks should be able to split
{
node: "ny153.example.com",
application: "apache",
time: "2011-01-02T21:21:56Z",
level: "ERROR",
msg: "something is broken"
}
Bad {node: 1}
95. Chunks should be able to split
{
node: "ny153.example.com",
application: "apache",
time: "2011-01-02T21:21:56Z",
level: "ERROR",
msg: "something is broken"
}
Bad {node: 1}
Better {node:1, time:1}
97. Writes should be distributed
{
node: "ny153.example.com",
application: "apache",
time: "2011-01-02T21:21:56Z",
level: "ERROR",
msg: "something is broken"
}
Bad { time : 1 }
98. Writes should be distributed
{
node: "ny153.example.com",
application: "apache",
time: "2011-01-02T21:21:56Z",
level: "ERROR",
msg: "something is broken"
}
Bad { time : 1 }
Better {node:1, application:1, time:1}
100. Queries should be routed to one shard
{
node: "ny153.example.com",
application: "apache",
time: "2011-01-02T21:21:56Z",
level: "ERROR",
msg: "something is broken”
}
Bad {msg: 1, node: 1}
101. Queries should be routed to one shard
{
node: "ny153.example.com",
application: "apache",
time: "2011-01-02T21:21:56Z",
level: "ERROR",
msg: "something is broken”
}
Bad {msg: 1, node: 1}
Better {node: 1, time: 1}