際際滷

際際滷Share a Scribd company logo
悋惘愆Sharding悋 惆悋惆 擧  惘惡惘
:擧惠愆惘  惆惘惡悋惘
惆悋惆擧慍惘  愕悋慍 悴悋慍 悋惡惘 惘悋悋愆 悋忰 惘悋 悋惘悋悧
悋惡惘 惘悋悋愆 悋 忰愀 悋惘惡 悋慍悋惘 惘 惠愕惺  惠惆 悋忰惘愀
惡惆悋愆惠  悛慍愆 悋惠惘悽悋惡 悋 慍 惆惘 悽惆悋惠 悋惘悋悧
惡悋惆 悋慍 忰悋惠OpenStack悋 惘悋 惆惘 擧惠愆惘 悋 惺悋  惡
悋悴 忰悋 悋OpenStack悋 惘悋
innfinision.net悋 惆悋惆 擧  惘惡惘 愆悋惘惆擯 悋惘愆
惘愕惠:
愆惠惘悋  惆悋愕惠悋 
Sharding愕惠
惡 慍悋 Sharding惆悋惘 悋慍
惆 Shard惆悋惘 悋慍
悋悋惺Sharding
擧 擯Shard Key擧 悋惠悽悋惡
惆Sharding
擯惘 惠悴
愆惠惘悋  惆悋愕惠悋 
悋 惆悋惆 擧  惘惡惘 愆悋惘惆擯 悋惘愆 innfinision.net
悋 惆悋惆 擧  惘惡惘 愆悋惘惆擯 悋惘愆 innfinision.net
Fouraquare:
蝱朧擧悋惘惡惘  
蝲)惘慍 惘慍 惆惘 忰惷惘 悋惺 悋惘惆朸(悋惡惆 悋慍悋愆  
蝱杁惺 惘惆 悋 擧悋   悋愀  
蝡朷擧惆 悋愕惠悋惆 惡悋慍悋惘悋惡 悋惘惡 悋惘惡 悋 悋慍惠悋悴惘  
蝥朧朧扣朧朧朧惓悋 惆惘 惺悋惠
蝱扛杁惆悋惘擧  悋愕悋惆  
悋 惆悋惆 擧  惘惡惘 愆悋惘惆擯 悋惘愆 innfinision.net
蝡霸) 悽愆cluster(mongoDB
杆) 悽惘惆 悋悛  悋慍 惠悋shard悋惆愆惆 (
) 悽愆 惡慍惘擯惠惘cluster(霸杁(悋 忰惷惘 )悋惺 惆悋惘惆 愆悋惘惆 惠悋
悋 惘擧悋惘惡  愆悋愕 惘惡惘 愆惆 悽惘惆
悋 惆悋惆 擧  惘惡惘 愆悋惘惆擯 悋惘愆 innfinision.net
悋 惆悋惆 擧  惘惡惘 愆悋惘惆擯 悋惘愆 innfinision.net
CarFax:
蝡朿悋愕悋惆 悋惘惆
蝡扛杁悋愕惠 愆惆 悋惷悋 愕悋惘 悋愕悋惆 悋惘惆
愆悋 悽惆惘惘 悋惘愆慍擯朮朧朧悋愕惠 愕惆
蝡朮shard
螄擯惘replica set
Replica惆惘 悋朿悋惆 愆惆 惠慍惺愕惠惘 惆惠悋
悋 惆悋惆 擧  惘惡惘 愆悋惘惆擯 悋惘愆 innfinision.net
悋 惆悋惆 擧  惘惡惘 愆悋惘惆擯 悋惘愆 innfinision.net
惠悴惠悴 MongoDBMongoDB 惷惺惠惷惺惠
≒惺擧惘惆朶愕惘惺惠惘悋惡惘惘惡
Scale out悋慍 悋愕惠悋惆 惡悋
惠 悋惘慍悋  愕惘惘悋
≒惆悋悽 悋慍擯 惆悋惘悋
≒惆拆悵惘 悋惺愀悋 愆悋
惆悋惆
≒ 愕悋慍擯悋惘
≒惠忰  惠悴慍
悋悋 惘 悋 惡惘惘愕 悋慍 拆愕NoSQL悋mongoDB.擧惘惆惆 悋惠悽悋惡 惘悋
MongoDB悵悽惘 忰
悋愕惠 悋惆悋惆 悋惶 愕悋慍
杁朧愕惘惘
霸朧愆悋惘惆
杁擯惘Replica Set惘 惆惘
愆悋惘惆
≒惠悋惘悽 惆悋惆 拆悋擯悋
悽惆惘
霸霸愕悋)惘 惘擧惘惆 悋惘惆霸
(愆惆  悋惷悋 悋惘惆
≒愕擯
≒拆惘慍
悋 惆悋惆 擧  惘惡惘 愆悋惘惆擯 悋惘愆 innfinision.net
Sharding愕惠
悋 惆悋惆 擧  惘惡惘 愆悋惘惆擯 悋惘愆 innfinision.net
PrimaryPrimary
SecondarySecondary
SecondarySecondary
Shard 1
PrimaryPrimary
SecondarySecondary
SecondarySecondary
Shard 2
PrimaryPrimary
SecondarySecondary
SecondarySecondary
Shard 3
PrimaryPrimary
SecondarySecondary
SecondarySecondary
Shard N

Query RouterQuery Router Query RouterQuery Router Query RouterQuery Router

DriverDriver
ApplicationApplication
悋 惆悋惆 擧  惘惡惘 愆悋惘惆擯 悋惘愆悋 惆悋惆 擧  惘惡惘 愆悋惘惆擯 悋惘愆 innfinision.net
惺 愕sharding:惆悋惘惆 悴惆
Hash-based
Range-based
Tag-aware
悋慍 悋愕悋愕惡惘 愕悋慍 悵悽惘 惷悋 擧惘惆  慍悋惆  擧
悽惆擧悋惘 愕悋慍 惠惺悋惆
悋 惆悋惆 擧  惘惡惘 愆悋惘惆擯 悋惘愆 innfinision.net
mongod
悽悋惆 /愆惠 拆悵惘 悋愕
Key Range
0..100
悋 惆悋惆 擧  惘惡惘 愆悋惘惆擯 悋惘愆 innfinision.net
mongod mongod
Key Range
0..50
Key Range
51..100
悽悋惆 /愆惠 拆悵惘 悋愕
悋 惆悋惆 擧  惘惡惘 愆悋惘惆擯 悋惘愆 innfinision.net
mongod mongod mongod mongod
Key Range
0..25
Key Range
26..50
Key Range
51..75
Key Range
76.. 100
悽悋惆 /愆惠 拆悵惘 悋愕
悋 惆悋惆 擧  惘惡惘 愆悋惘惆擯 悋惘愆 innfinision.net
惡 慍悋 Sharding惆悋惘 悋慍
悋 惆悋惆 擧  惘惡惘 愆悋惘惆擯 悋惘愆 innfinision.net
悋 愕惘惘 擧 悛悋Replica set:
惡悋愆惆 悋愀惺悋惠 惠悋 愕悋慍 悵悽惘 悋惘惡 擧悋 惷悋 惆悋惘悋
惺悋惠 惠悋  惡 惠悋惆query擧惆 惘愕惆擯 悋
惠悋 惡 惠悋惆query惆惆 拆悋愕悽 愕惘惺悋 悋
愕惘惘 愆悽惶悋惠
Disk Capacity
Disk IOPS
RAM
Network
Disk IOPS
RAM
Network
悋 惆悋惆 擧  惘惡惘 愆悋惘惆擯 悋惘愆 innfinision.net
惆 惡Shard惆悋惘 悋慍
悋 惆悋惆 擧  惘惡惘 愆悋惘惆擯 悋惘愆 innfinision.net
: 惆愕擧 惷悋
.惡悋愆惆 悋慍 惘惆 愕悋慍 悵悽惘 悋惆悋慍 悋慍惡愆惠惘 惡悋惆 愆悋惘惆悋 惠悋 惆惘 惆愕擧 惷悋 悴惺
:惓悋
= 擧 愕悋慍 悵悽惘  悋惆悋惘3TB
= 愕惘惘 愕悋慍 悵悽惘  悋惆悋慍2TB
惡朮惆悋惘 悋慍 愆悋惘惆
:惓悋
= 擧 愕悋慍 悵悽惘  悋惆悋惘3TB
= 愕惘惘 愕悋慍 悵悽惘  悋惆悋慍2TB
惡朮惆悋惘 悋慍 愆悋惘惆
悋 惆悋惆 擧  惘惡惘 愆悋惘惆擯 悋惘愆 innfinision.net
Sharding惆惘RAM:
悴惺RAM< 悋 愆悋惘惆悋愕惘惘愕 惆惘Workset
Workset愆惆 惆惆惡愆惠惘 悋悋 愃悋惡 擧 悋愕悋惆 悋慍 悋悴惺 =
Workset惆惘RAM:
擧惠惘惠悖悽惘 慍悋 
惡悋惠惘 惺悋惠 惠悋 
惓悋
Working Set = 428 GB
Server RAM = 128 GB
朶朮杆 / 霸朮杆 = 朿朿朶
惡朶惆悋惘 悋慍 愆悋惘惆
惓悋
Working Set = 428 GB
Server RAM = 128 GB
朶朮杆 / 霸朮杆 = 朿朿朶
惡朶惆悋惘 悋慍 愆悋惘惆
悋 惆悋惆 擧  惘惡惘 愆悋惘惆擯 悋惘愆 innfinision.net
) 擧悋惘 悴惺  愆悋悽惶 忰悴 擯惘悋惆悋慍Working Set & Index Size(
: 悴惺惘 愆悋悽惶 悋惆悋慍
db.stats()
:擧悋惘 悴惺 忰悴 忰惆惆
db.serverStatus({workingSet:1})
悋 惆悋惆 擧  惘惡惘 愆悋惘惆擯 悋惘愆 innfinision.net
: 惆愕擧 惺悋惠 惠悋 
悴惺IOPS悋慍惡愆惠惘 惡悋惆 悋 愆悋惘惆悋愕惘惘愕 惆惘IOPS惡悋愆惆 悋慍 惘惆
悛惘惆惘惡IOPS悋愕惠 惆愆悋惘 惡愕悋惘
惠惷忰悋惠 惘愕悋 惘慍 惡
悋 愆悋悽惶 惘愕悋 惘慍 惡
悴惘悋 惡 擧惘惆  悋惷悋
擯 惡 惘惆
擯惘 悋惆悋慍  悋  擧 愕悋悽惠 :惘愆 惡惠惘
悋 惆悋惆 擧  惘惡惘 愆悋惘惆擯 悋惘愆 innfinision.net
: 惆愕擧 惺悋惠 惠悋 
悴惺IOPS悋慍惡愆惠惘 惡悋惆 悋 愆悋惘惆悋愕惘惘愕 惆惘IOPS惡悋愆惆 悋慍 惘惆
悛惘惆惘惡IOPS悋愕惠 惆愆悋惘 惡愕悋惘
惠惷忰悋惠 惘愕悋 惘慍 惡
悋 愆悋悽惶 惘愕悋 惘慍 惡
悴惘悋 惡 擧惘惆  悋惷悋
擯 惡 惘惆
擯惘 悋惆悋慍  悋  擧 愕悋悽惠 :惘愆 惡惠惘
惓悋
IOPS= 悋慍 惘惆霸霸朧朧朧
IOPS= 愕惘惘杁朧朧朧
惡朿惆悋惘 悋慍 愆悋惘惆
惓悋
IOPS= 悋慍 惘惆霸霸朧朧朧
IOPS= 愕惘惘杁朧朧朧
惡朿惆悋惘 悋慍 愆悋惘惆
悋 惆悋惆 擧  惘惡惘 愆悋惘惆擯 悋惘愆 innfinision.net
) 惓悋 惆惘 惺悋惠OPS: (
S愕惘惘 擧 惓悋 惆惘 惺悋惠 =
G悋慍 惘惆 惓悋 惆惘 惺悋惠 =
N悋 愆悋惘惆 惠惺惆悋惆 =
G = N * S * 0.7
N = (G / 0.7S)
悋 惆悋惆 擧  惘惡惘 愆悋惘惆擯 悋惘愆 innfinision.net
) 惓悋 惆惘 惺悋惠OPS: (
S愕惘惘 擧 惓悋 惆惘 惺悋惠 =
G悋慍 惘惆 惓悋 惆惘 惺悋惠 =
N悋 愆悋惘惆 惠惺惆悋惆 =
G = N * S * 0.7
N = (G / 0.7S)
Sharding悋Sharding悋
悋 惆悋惆 擧  惘惡惘 愆悋惘惆擯 悋惘愆 innfinision.net
) 惓悋 惆惘 惺悋惠OPS: (
S愕惘惘 擧 惓悋 惆惘 惺悋惠 =
G悋慍 惘惆 惓悋 惆惘 惺悋惠 =
N悋 愆悋惘惆 惠惺惆悋惆 =
G = N * S * 0.7
N = (G / 0.7S)
惓悋
S = 朶朧朧朧
G = 霸朧朧朧朧
N = 朿杁朷
惡朶惆悋惘 悋慍 愆悋惘惆
惓悋
S = 朶朧朧朧
G = 霸朧朧朧朧
N = 朿杁朷
惡朶惆悋惘 悋慍 愆悋惘惆
悋 惆悋惆 擧  惘惡惘 愆悋惘惆擯 悋惘愆 innfinision.net
悋悋惺Sharding
悋 惆悋惆 擧  惘惡惘 愆悋惘惆擯 悋惘愆 innfinision.net
Range Sharding
mongod mongod mongod mongod
Key Range
0..25
Key Range
26..50
Key Range
51..75
Key Range
76.. 100
悽悋惆 /愆惠 拆悵惘 悋愕
悋 惆悋惆 擧  惘惡惘 愆悋惘惆擯 悋惘愆 innfinision.net
Tag Aware Sharding
mongod mongod mongod mongod
Shard Tags
Shard Tag 愆惘惺 拆悋悋 
慍愕惠悋  23 Dec 21 Mar
惡悋惘 22 Mar 21 Jun
惠悋惡愕惠悋  21 Jun 23 Sep
拆悋慍 24 Sep 22 Dec
Tag Ranges
慍愕惠悋  惡悋惘 惠悋惡愕惠悋  拆悋慍
悋 惆悋惆 擧  惘惡惘 愆悋惘惆擯 悋惘愆 innfinision.net
Hash Sharding
mongod mongod mongod mongod
Hash Range
0000..4444
Hash Range
4445..8000
Hash Range
i8001..aaaa
Hash Range
aaab..ffff
悋 惆悋惆 擧  惘惡惘 愆悋惘惆擯 悋惘愆 innfinision.net
Hash Sharding
: 悋悋慍
.愆惆 惠慍惺 愕悋 惶惘惠 惡 悋惆悋惆
: 惺悋惡
.悛惆 惆惘 愆惘惆 惶惘惠 惡 悋 愆悋悽惶  惠惶悋惆 悋惆悋惆 惡惘慍惘愕悋 悽惘悴  惘惆
.悛惆 惆惘 悋擧惆惘拆 惶惘惠 惡 愕惠惆 忰惆惆 悋愕悋愕惡惘 擧 悋 悴  拆惘愕
悋 惆悋惆 擧  惘惡惘 愆悋惘惆擯 悋惘愆 innfinision.net
Range Sharding Document Distribution
悋 惆悋惆 擧  惘惡惘 愆悋惘惆擯 悋惘愆 innfinision.net
Hashed Sharding Document Distribution
悋 惆悋惆 擧  惘惡惘 愆悋惘惆擯 悋惘愆 innfinision.net
擧 擯Shard Key擧 悋惠悽悋惡
悋 惆悋惆 擧  惘惡惘 愆悋惘惆擯 悋惘愆 innfinision.net
擧Shard Key: 悽惡
.惆悋惘惆 擧悋 擧悋惘惆悋惠
.擧惆  惠慍惺 愕悋 惶惘惠 惡 惘悋 悋愆惠
)悋慍悋 悽悋惆 惆悋惘 惆query.(悋
Shard Key  惆惘 悋擧悋  惶惘惠 惆惘query: 惡悋愆惆 悋
.愆惆 悛惘 悴惺 悋擧惆惘拆 惶惘惠 悋愃惘 惆惘
悋 惆悋惆 擧  惘惡惘 愆悋惘惆擯 悋惘愆 innfinision.net
擧 悋惠悽悋惡Shard Key: 悋愕惠  悽惡
.惆悋惘惆 慍悋惆惠悖惓惘 拆悵惘 悋愕  惺擧惘惆惡惘
.惡惆 悽悋惆 惠 悋 惘擯 悛  惆悋惆 惠愃惘 悋悋 惡惺惆
悋 惆悋惆 擧  惘惡惘 愆悋惘惆擯 悋惘愆 innfinision.net
 Induces jumbo chunks
 Examples: boolean field
 Monotonically increasing shard key values cause hot
spots on inserts
 Examples: timestamps, _id
悋 惆悋惆 擧  惘惡惘 愆悋惘惆擯 悋惘愆 innfinision.net
惆Sharding
悋 惆悋惆 擧  惘惡惘 愆悋惘惆擯 悋惘愆 innfinision.net
: 拆悵惘 悋愕
悋惆悋惆 忰悴
悋 悴  拆惘愕 忰悴
: 忰 悋愆惠 惡悋 悴悋 悋惘惘悋愕惠
悋悋惘悴愃 悋慍 惡惆  悛擯悋 悋惡惠 惡悋 愆悋惘惆擯
愆惆 惡惆 愀惡 愕悋慍 悵悽惘
悋 拆愆惠惡悋 愕惘惺 惡悋慍擯惘惆悋惆 
悋 惆悋惆 擧  惘惡惘 愆悋惘惆擯 悋惘愆 innfinision.net
忰 悋愆惠 惡悋 悴悋 悋惘惘悋愕惠
Primary:NYC
Secondary:NYC
Primary:LON
Primary:SYD
Secondary:LON
Secondary:NYC
Secondary:SYD
Secondary:LON
Secondary:SYD
悋 惆悋惆 擧  惘惡惘 愆悋惘惆擯 悋惘愆 innfinision.net
愆惆 惡惆  愕悋慍 悵悽惘
悋 悋慍悋惘愕悽惠 慍 惆惘 悴 惶惘
愕惘惺惠惘 悋 愕惘惘 惘 悋惆惆悋愆惠 惆愕惠惘愕惡愆惠惘 擧 悋愕悋惆 惆悋惆  悋惘惘
擧惆惠惘 悋 愕惘惘 惘 悋愕悋惆  悋惆悋惆 擯惘惠 悋惘惘
悋慍 悋愕惠悋惆Tag Aware Sharding
mongod mongod mongod mongod
惺 惺 悛惘愆 悛惘愆
SSDSSD SSDSSD HDDHDD HDDHDD
悋 惆悋惆 擧  惘惡惘 愆悋惘惆擯 悋惘愆 innfinision.net
愕惘惺 惡悋慍擯惘惆悋惆 
惆惠悋惡愕朶朧悋惡悋惠惘惠
蝤愆悋惘惆朮朧悋惡悋惠惘惠
: 悋愆

mongod mongod
20 TB 20 TB
悋 惆悋惆 擧  惘惡惘 愆悋惘惆擯 悋惘愆 innfinision.net
愕惘惺 惡悋慍擯惘惆悋惆 
惆惠悋惡愕朶朧悋惡悋惠惘惠
蝯愆悋惘惆霸朧悋惡悋惠惘惠
: 悋愆
悋愀惺悋惠 惡悋慍擯惘惆悋惆 杁朧.擯惘惆 悋悴悋愕惘惺惠惘 %
mongod mongod
10 TB 10 TB
mongod mongod
10 TB 10 TB
悋 惆悋惆 擧  惘惡惘 愆悋惘惆擯 悋惘愆 innfinision.net
擯惘惠悴
悋 惆悋惆 擧  惘惡惘 愆悋惘惆擯 悋惘愆 innfinision.net
:擧惆 惡惘惘愕 惘悋慍惘 擧悋惠 悋慍 惘惆 悋 愆悋惘惆 惠惺 悋惘惡
悋慍 惘惆 愕悋慍 悵悽惘
惠悋悽惘 慍悋  愕惘惺惠
悋慍 惘惆 惺悋惠 惠悋 
: 擧 愆惠
惆愕擧 惴惘惠
惆愕擧 惠悋 
惘
.擧惆 惠惺 悋 愕惘惘 惘惆 愆悽惶悋惠 悋愕悋愕惡惘 惘悋 悋 愆悋惘惆 惠惺惆悋惆
悋 惆悋惆 擧  惘惡惘 愆悋惘惆擯 悋惘愆 innfinision.net
惠 悋愀Sharding:
拆悵惘 悋愕
悋悋惘悴愃 悋慍 惡惆  悛擯悋 悋惡惠 惡悋 悋擧愕惠惘
愆惆 惡惆 愀惡 愕悋慍 悵悽惘
悋 拆愆惠惡悋 愕惘惺 惡悋慍擯惘惆悋惆 
悋 惆悋惆 擧  惘惡惘 愆悋惘惆擯 悋惘愆 innfinision.net
惠愆擧惘
Ali Hallaji
Ali.Hallaji@innfinision.net
innfinision.net

More Related Content

Sharding

  • 2. :擧惠愆惘 惆惘惡悋惘 惆悋惆擧慍惘 愕悋慍 悴悋慍 悋惡惘 惘悋悋愆 悋忰 惘悋 悋惘悋悧 悋惡惘 惘悋悋愆 悋 忰愀 悋惘惡 悋慍悋惘 惘 惠愕惺 惠惆 悋忰惘愀 惡惆悋愆惠 悛慍愆 悋惠惘悽悋惡 悋 慍 惆惘 悽惆悋惠 悋惘悋悧 惡悋惆 悋慍 忰悋惠OpenStack悋 惘悋 惆惘 擧惠愆惘 悋 惺悋 惡 悋悴 忰悋 悋OpenStack悋 惘悋
  • 3. innfinision.net悋 惆悋惆 擧 惘惡惘 愆悋惘惆擯 悋惘愆 惘愕惠: 愆惠惘悋 惆悋愕惠悋 Sharding愕惠 惡 慍悋 Sharding惆悋惘 悋慍 惆 Shard惆悋惘 悋慍 悋悋惺Sharding 擧 擯Shard Key擧 悋惠悽悋惡 惆Sharding 擯惘 惠悴
  • 4. 愆惠惘悋 惆悋愕惠悋 悋 惆悋惆 擧 惘惡惘 愆悋惘惆擯 悋惘愆 innfinision.net
  • 5. 悋 惆悋惆 擧 惘惡惘 愆悋惘惆擯 悋惘愆 innfinision.net
  • 6. Fouraquare: 蝱朧擧悋惘惡惘 蝲)惘慍 惘慍 惆惘 忰惷惘 悋惺 悋惘惆朸(悋惡惆 悋慍悋愆 蝱杁惺 惘惆 悋 擧悋 悋愀 蝡朷擧惆 悋愕惠悋惆 惡悋慍悋惘悋惡 悋惘惡 悋惘惡 悋 悋慍惠悋悴惘 蝥朧朧扣朧朧朧惓悋 惆惘 惺悋惠 蝱扛杁惆悋惘擧 悋愕悋惆 悋 惆悋惆 擧 惘惡惘 愆悋惘惆擯 悋惘愆 innfinision.net
  • 7. 蝡霸) 悽愆cluster(mongoDB 杆) 悽惘惆 悋悛 悋慍 惠悋shard悋惆愆惆 ( ) 悽愆 惡慍惘擯惠惘cluster(霸杁(悋 忰惷惘 )悋惺 惆悋惘惆 愆悋惘惆 惠悋 悋 惘擧悋惘惡 愆悋愕 惘惡惘 愆惆 悽惘惆 悋 惆悋惆 擧 惘惡惘 愆悋惘惆擯 悋惘愆 innfinision.net
  • 8. 悋 惆悋惆 擧 惘惡惘 愆悋惘惆擯 悋惘愆 innfinision.net
  • 9. CarFax: 蝡朿悋愕悋惆 悋惘惆 蝡扛杁悋愕惠 愆惆 悋惷悋 愕悋惘 悋愕悋惆 悋惘惆 愆悋 悽惆惘惘 悋惘愆慍擯朮朧朧悋愕惠 愕惆 蝡朮shard 螄擯惘replica set Replica惆惘 悋朿悋惆 愆惆 惠慍惺愕惠惘 惆惠悋 悋 惆悋惆 擧 惘惡惘 愆悋惘惆擯 悋惘愆 innfinision.net
  • 10. 悋 惆悋惆 擧 惘惡惘 愆悋惘惆擯 悋惘愆 innfinision.net
  • 11. 惠悴惠悴 MongoDBMongoDB 惷惺惠惷惺惠 ≒惺擧惘惆朶愕惘惺惠惘悋惡惘惘惡 Scale out悋慍 悋愕惠悋惆 惡悋 惠 悋惘慍悋 愕惘惘悋 ≒惆悋悽 悋慍擯 惆悋惘悋 ≒惆拆悵惘 悋惺愀悋 愆悋 惆悋惆 ≒ 愕悋慍擯悋惘 ≒惠忰 惠悴慍 悋悋 惘 悋 惡惘惘愕 悋慍 拆愕NoSQL悋mongoDB.擧惘惆惆 悋惠悽悋惡 惘悋 MongoDB悵悽惘 忰 悋愕惠 悋惆悋惆 悋惶 愕悋慍 杁朧愕惘惘 霸朧愆悋惘惆 杁擯惘Replica Set惘 惆惘 愆悋惘惆 ≒惠悋惘悽 惆悋惆 拆悋擯悋 悽惆惘 霸霸愕悋)惘 惘擧惘惆 悋惘惆霸 (愆惆 悋惷悋 悋惘惆 ≒愕擯 ≒拆惘慍 悋 惆悋惆 擧 惘惡惘 愆悋惘惆擯 悋惘愆 innfinision.net
  • 12. Sharding愕惠 悋 惆悋惆 擧 惘惡惘 愆悋惘惆擯 悋惘愆 innfinision.net
  • 13. PrimaryPrimary SecondarySecondary SecondarySecondary Shard 1 PrimaryPrimary SecondarySecondary SecondarySecondary Shard 2 PrimaryPrimary SecondarySecondary SecondarySecondary Shard 3 PrimaryPrimary SecondarySecondary SecondarySecondary Shard N Query RouterQuery Router Query RouterQuery Router Query RouterQuery Router DriverDriver ApplicationApplication 悋 惆悋惆 擧 惘惡惘 愆悋惘惆擯 悋惘愆悋 惆悋惆 擧 惘惡惘 愆悋惘惆擯 悋惘愆 innfinision.net
  • 14. 惺 愕sharding:惆悋惘惆 悴惆 Hash-based Range-based Tag-aware 悋慍 悋愕悋愕惡惘 愕悋慍 悵悽惘 惷悋 擧惘惆 慍悋惆 擧 悽惆擧悋惘 愕悋慍 惠惺悋惆 悋 惆悋惆 擧 惘惡惘 愆悋惘惆擯 悋惘愆 innfinision.net
  • 15. mongod 悽悋惆 /愆惠 拆悵惘 悋愕 Key Range 0..100 悋 惆悋惆 擧 惘惡惘 愆悋惘惆擯 悋惘愆 innfinision.net
  • 16. mongod mongod Key Range 0..50 Key Range 51..100 悽悋惆 /愆惠 拆悵惘 悋愕 悋 惆悋惆 擧 惘惡惘 愆悋惘惆擯 悋惘愆 innfinision.net
  • 17. mongod mongod mongod mongod Key Range 0..25 Key Range 26..50 Key Range 51..75 Key Range 76.. 100 悽悋惆 /愆惠 拆悵惘 悋愕 悋 惆悋惆 擧 惘惡惘 愆悋惘惆擯 悋惘愆 innfinision.net
  • 18. 惡 慍悋 Sharding惆悋惘 悋慍 悋 惆悋惆 擧 惘惡惘 愆悋惘惆擯 悋惘愆 innfinision.net
  • 19. 悋 愕惘惘 擧 悛悋Replica set: 惡悋愆惆 悋愀惺悋惠 惠悋 愕悋慍 悵悽惘 悋惘惡 擧悋 惷悋 惆悋惘悋 惺悋惠 惠悋 惡 惠悋惆query擧惆 惘愕惆擯 悋 惠悋 惡 惠悋惆query惆惆 拆悋愕悽 愕惘惺悋 悋 愕惘惘 愆悽惶悋惠 Disk Capacity Disk IOPS RAM Network Disk IOPS RAM Network 悋 惆悋惆 擧 惘惡惘 愆悋惘惆擯 悋惘愆 innfinision.net
  • 20. 惆 惡Shard惆悋惘 悋慍 悋 惆悋惆 擧 惘惡惘 愆悋惘惆擯 悋惘愆 innfinision.net
  • 21. : 惆愕擧 惷悋 .惡悋愆惆 悋慍 惘惆 愕悋慍 悵悽惘 悋惆悋慍 悋慍惡愆惠惘 惡悋惆 愆悋惘惆悋 惠悋 惆惘 惆愕擧 惷悋 悴惺 :惓悋 = 擧 愕悋慍 悵悽惘 悋惆悋惘3TB = 愕惘惘 愕悋慍 悵悽惘 悋惆悋慍2TB 惡朮惆悋惘 悋慍 愆悋惘惆 :惓悋 = 擧 愕悋慍 悵悽惘 悋惆悋惘3TB = 愕惘惘 愕悋慍 悵悽惘 悋惆悋慍2TB 惡朮惆悋惘 悋慍 愆悋惘惆 悋 惆悋惆 擧 惘惡惘 愆悋惘惆擯 悋惘愆 innfinision.net
  • 22. Sharding惆惘RAM: 悴惺RAM< 悋 愆悋惘惆悋愕惘惘愕 惆惘Workset Workset愆惆 惆惆惡愆惠惘 悋悋 愃悋惡 擧 悋愕悋惆 悋慍 悋悴惺 = Workset惆惘RAM: 擧惠惘惠悖悽惘 慍悋 惡悋惠惘 惺悋惠 惠悋 惓悋 Working Set = 428 GB Server RAM = 128 GB 朶朮杆 / 霸朮杆 = 朿朿朶 惡朶惆悋惘 悋慍 愆悋惘惆 惓悋 Working Set = 428 GB Server RAM = 128 GB 朶朮杆 / 霸朮杆 = 朿朿朶 惡朶惆悋惘 悋慍 愆悋惘惆 悋 惆悋惆 擧 惘惡惘 愆悋惘惆擯 悋惘愆 innfinision.net
  • 23. ) 擧悋惘 悴惺 愆悋悽惶 忰悴 擯惘悋惆悋慍Working Set & Index Size( : 悴惺惘 愆悋悽惶 悋惆悋慍 db.stats() :擧悋惘 悴惺 忰悴 忰惆惆 db.serverStatus({workingSet:1}) 悋 惆悋惆 擧 惘惡惘 愆悋惘惆擯 悋惘愆 innfinision.net
  • 24. : 惆愕擧 惺悋惠 惠悋 悴惺IOPS悋慍惡愆惠惘 惡悋惆 悋 愆悋惘惆悋愕惘惘愕 惆惘IOPS惡悋愆惆 悋慍 惘惆 悛惘惆惘惡IOPS悋愕惠 惆愆悋惘 惡愕悋惘 惠惷忰悋惠 惘愕悋 惘慍 惡 悋 愆悋悽惶 惘愕悋 惘慍 惡 悴惘悋 惡 擧惘惆 悋惷悋 擯 惡 惘惆 擯惘 悋惆悋慍 悋 擧 愕悋悽惠 :惘愆 惡惠惘 悋 惆悋惆 擧 惘惡惘 愆悋惘惆擯 悋惘愆 innfinision.net
  • 25. : 惆愕擧 惺悋惠 惠悋 悴惺IOPS悋慍惡愆惠惘 惡悋惆 悋 愆悋惘惆悋愕惘惘愕 惆惘IOPS惡悋愆惆 悋慍 惘惆 悛惘惆惘惡IOPS悋愕惠 惆愆悋惘 惡愕悋惘 惠惷忰悋惠 惘愕悋 惘慍 惡 悋 愆悋悽惶 惘愕悋 惘慍 惡 悴惘悋 惡 擧惘惆 悋惷悋 擯 惡 惘惆 擯惘 悋惆悋慍 悋 擧 愕悋悽惠 :惘愆 惡惠惘 惓悋 IOPS= 悋慍 惘惆霸霸朧朧朧 IOPS= 愕惘惘杁朧朧朧 惡朿惆悋惘 悋慍 愆悋惘惆 惓悋 IOPS= 悋慍 惘惆霸霸朧朧朧 IOPS= 愕惘惘杁朧朧朧 惡朿惆悋惘 悋慍 愆悋惘惆 悋 惆悋惆 擧 惘惡惘 愆悋惘惆擯 悋惘愆 innfinision.net
  • 26. ) 惓悋 惆惘 惺悋惠OPS: ( S愕惘惘 擧 惓悋 惆惘 惺悋惠 = G悋慍 惘惆 惓悋 惆惘 惺悋惠 = N悋 愆悋惘惆 惠惺惆悋惆 = G = N * S * 0.7 N = (G / 0.7S) 悋 惆悋惆 擧 惘惡惘 愆悋惘惆擯 悋惘愆 innfinision.net
  • 27. ) 惓悋 惆惘 惺悋惠OPS: ( S愕惘惘 擧 惓悋 惆惘 惺悋惠 = G悋慍 惘惆 惓悋 惆惘 惺悋惠 = N悋 愆悋惘惆 惠惺惆悋惆 = G = N * S * 0.7 N = (G / 0.7S) Sharding悋Sharding悋 悋 惆悋惆 擧 惘惡惘 愆悋惘惆擯 悋惘愆 innfinision.net
  • 28. ) 惓悋 惆惘 惺悋惠OPS: ( S愕惘惘 擧 惓悋 惆惘 惺悋惠 = G悋慍 惘惆 惓悋 惆惘 惺悋惠 = N悋 愆悋惘惆 惠惺惆悋惆 = G = N * S * 0.7 N = (G / 0.7S) 惓悋 S = 朶朧朧朧 G = 霸朧朧朧朧 N = 朿杁朷 惡朶惆悋惘 悋慍 愆悋惘惆 惓悋 S = 朶朧朧朧 G = 霸朧朧朧朧 N = 朿杁朷 惡朶惆悋惘 悋慍 愆悋惘惆 悋 惆悋惆 擧 惘惡惘 愆悋惘惆擯 悋惘愆 innfinision.net
  • 29. 悋悋惺Sharding 悋 惆悋惆 擧 惘惡惘 愆悋惘惆擯 悋惘愆 innfinision.net
  • 30. Range Sharding mongod mongod mongod mongod Key Range 0..25 Key Range 26..50 Key Range 51..75 Key Range 76.. 100 悽悋惆 /愆惠 拆悵惘 悋愕 悋 惆悋惆 擧 惘惡惘 愆悋惘惆擯 悋惘愆 innfinision.net
  • 31. Tag Aware Sharding mongod mongod mongod mongod Shard Tags Shard Tag 愆惘惺 拆悋悋 慍愕惠悋 23 Dec 21 Mar 惡悋惘 22 Mar 21 Jun 惠悋惡愕惠悋 21 Jun 23 Sep 拆悋慍 24 Sep 22 Dec Tag Ranges 慍愕惠悋 惡悋惘 惠悋惡愕惠悋 拆悋慍 悋 惆悋惆 擧 惘惡惘 愆悋惘惆擯 悋惘愆 innfinision.net
  • 32. Hash Sharding mongod mongod mongod mongod Hash Range 0000..4444 Hash Range 4445..8000 Hash Range i8001..aaaa Hash Range aaab..ffff 悋 惆悋惆 擧 惘惡惘 愆悋惘惆擯 悋惘愆 innfinision.net
  • 33. Hash Sharding : 悋悋慍 .愆惆 惠慍惺 愕悋 惶惘惠 惡 悋惆悋惆 : 惺悋惡 .悛惆 惆惘 愆惘惆 惶惘惠 惡 悋 愆悋悽惶 惠惶悋惆 悋惆悋惆 惡惘慍惘愕悋 悽惘悴 惘惆 .悛惆 惆惘 悋擧惆惘拆 惶惘惠 惡 愕惠惆 忰惆惆 悋愕悋愕惡惘 擧 悋 悴 拆惘愕 悋 惆悋惆 擧 惘惡惘 愆悋惘惆擯 悋惘愆 innfinision.net
  • 34. Range Sharding Document Distribution 悋 惆悋惆 擧 惘惡惘 愆悋惘惆擯 悋惘愆 innfinision.net
  • 35. Hashed Sharding Document Distribution 悋 惆悋惆 擧 惘惡惘 愆悋惘惆擯 悋惘愆 innfinision.net
  • 36. 擧 擯Shard Key擧 悋惠悽悋惡 悋 惆悋惆 擧 惘惡惘 愆悋惘惆擯 悋惘愆 innfinision.net
  • 37. 擧Shard Key: 悽惡 .惆悋惘惆 擧悋 擧悋惘惆悋惠 .擧惆 惠慍惺 愕悋 惶惘惠 惡 惘悋 悋愆惠 )悋慍悋 悽悋惆 惆悋惘 惆query.(悋 Shard Key 惆惘 悋擧悋 惶惘惠 惆惘query: 惡悋愆惆 悋 .愆惆 悛惘 悴惺 悋擧惆惘拆 惶惘惠 悋愃惘 惆惘 悋 惆悋惆 擧 惘惡惘 愆悋惘惆擯 悋惘愆 innfinision.net
  • 38. 擧 悋惠悽悋惡Shard Key: 悋愕惠 悽惡 .惆悋惘惆 慍悋惆惠悖惓惘 拆悵惘 悋愕 惺擧惘惆惡惘 .惡惆 悽悋惆 惠 悋 惘擯 悛 惆悋惆 惠愃惘 悋悋 惡惺惆 悋 惆悋惆 擧 惘惡惘 愆悋惘惆擯 悋惘愆 innfinision.net
  • 39. Induces jumbo chunks Examples: boolean field Monotonically increasing shard key values cause hot spots on inserts Examples: timestamps, _id 悋 惆悋惆 擧 惘惡惘 愆悋惘惆擯 悋惘愆 innfinision.net
  • 40. 惆Sharding 悋 惆悋惆 擧 惘惡惘 愆悋惘惆擯 悋惘愆 innfinision.net
  • 41. : 拆悵惘 悋愕 悋惆悋惆 忰悴 悋 悴 拆惘愕 忰悴 : 忰 悋愆惠 惡悋 悴悋 悋惘惘悋愕惠 悋悋惘悴愃 悋慍 惡惆 悛擯悋 悋惡惠 惡悋 愆悋惘惆擯 愆惆 惡惆 愀惡 愕悋慍 悵悽惘 悋 拆愆惠惡悋 愕惘惺 惡悋慍擯惘惆悋惆 悋 惆悋惆 擧 惘惡惘 愆悋惘惆擯 悋惘愆 innfinision.net
  • 42. 忰 悋愆惠 惡悋 悴悋 悋惘惘悋愕惠 Primary:NYC Secondary:NYC Primary:LON Primary:SYD Secondary:LON Secondary:NYC Secondary:SYD Secondary:LON Secondary:SYD 悋 惆悋惆 擧 惘惡惘 愆悋惘惆擯 悋惘愆 innfinision.net
  • 43. 愆惆 惡惆 愕悋慍 悵悽惘 悋 悋慍悋惘愕悽惠 慍 惆惘 悴 惶惘 愕惘惺惠惘 悋 愕惘惘 惘 悋惆惆悋愆惠 惆愕惠惘愕惡愆惠惘 擧 悋愕悋惆 惆悋惆 悋惘惘 擧惆惠惘 悋 愕惘惘 惘 悋愕悋惆 悋惆悋惆 擯惘惠 悋惘惘 悋慍 悋愕惠悋惆Tag Aware Sharding mongod mongod mongod mongod 惺 惺 悛惘愆 悛惘愆 SSDSSD SSDSSD HDDHDD HDDHDD 悋 惆悋惆 擧 惘惡惘 愆悋惘惆擯 悋惘愆 innfinision.net
  • 44. 愕惘惺 惡悋慍擯惘惆悋惆 惆惠悋惡愕朶朧悋惡悋惠惘惠 蝤愆悋惘惆朮朧悋惡悋惠惘惠 : 悋愆 mongod mongod 20 TB 20 TB 悋 惆悋惆 擧 惘惡惘 愆悋惘惆擯 悋惘愆 innfinision.net
  • 45. 愕惘惺 惡悋慍擯惘惆悋惆 惆惠悋惡愕朶朧悋惡悋惠惘惠 蝯愆悋惘惆霸朧悋惡悋惠惘惠 : 悋愆 悋愀惺悋惠 惡悋慍擯惘惆悋惆 杁朧.擯惘惆 悋悴悋愕惘惺惠惘 % mongod mongod 10 TB 10 TB mongod mongod 10 TB 10 TB 悋 惆悋惆 擧 惘惡惘 愆悋惘惆擯 悋惘愆 innfinision.net
  • 46. 擯惘惠悴 悋 惆悋惆 擧 惘惡惘 愆悋惘惆擯 悋惘愆 innfinision.net
  • 47. :擧惆 惡惘惘愕 惘悋慍惘 擧悋惠 悋慍 惘惆 悋 愆悋惘惆 惠惺 悋惘惡 悋慍 惘惆 愕悋慍 悵悽惘 惠悋悽惘 慍悋 愕惘惺惠 悋慍 惘惆 惺悋惠 惠悋 : 擧 愆惠 惆愕擧 惴惘惠 惆愕擧 惠悋 惘 .擧惆 惠惺 悋 愕惘惘 惘惆 愆悽惶悋惠 悋愕悋愕惡惘 惘悋 悋 愆悋惘惆 惠惺惆悋惆 悋 惆悋惆 擧 惘惡惘 愆悋惘惆擯 悋惘愆 innfinision.net
  • 48. 惠 悋愀Sharding: 拆悵惘 悋愕 悋悋惘悴愃 悋慍 惡惆 悛擯悋 悋惡惠 惡悋 悋擧愕惠惘 愆惆 惡惆 愀惡 愕悋慍 悵悽惘 悋 拆愆惠惡悋 愕惘惺 惡悋慍擯惘惆悋惆 悋 惆悋惆 擧 惘惡惘 愆悋惘惆擯 悋惘愆 innfinision.net