SlideShare une entreprise Scribd logo
1  sur  14
Télécharger pour lire hors ligne
All about the Cluster
Balancer in MongoDB
MongoDB Meetup Oct 2013
David Murphy
DBA, ObjectRocket
@dmurphy_data @objectrocket
Overview
1)What is sharding?
2)What does the balancer do?
3)Migration phases
4)What is an orphan, and why do I care?
5)Balanced chunks, but not disk space? What can you do?

!
What is sharding?
Definition

A method to horizontally scale out software/database layers

Key terms

!

Shard
Replication Set
Chunk
Balancer
Config Server
Mongos

A specific replication set part of a larger cluster
Set of mongod servers setup as “Primary’s” and “Secondary's”
Logical unit of documents used for moving data between shards
Process on mongos that ensures even chunk counts over shards
Stores metadata used by mongos
Central router for queries to mongo shards

Why?
Needed to enable the linear scalability part to the mongo stack.
Servers have limited resources, enables using more servers to get more resources.
What does the Cluster Balancer do?
Does:

Does not:

Manage chunk count balance

Split chunks

Clone chunks

Merge chunk

Apply oplog to clones

Balance disk space

Remove duplicate documents

Remove orphans documents
Phase of a chunk migration
1.Parse arguments and prepare
2.Check config and lock
3.Find documents on donor and sort
4.Copy the chunk to destination shard
5.Global lock, log change, update config
6.Clean up and unlock
Phase1 - Parse and prepare
1) Check if cluster is running healthy and majority
2) Ensure running in replset not master/slave
3) Ensure collection is replicated
4) Collect metadata for later phases

!
Phase2 - Check and lock

1)Check for active migration lock
2) Take distributed lock
3) Log event to “config.changelog”
4) Do final check of chunk boundaries and owning shard
5) Validate mongod versions match

!
Phase3 - Find and sort
1) Check locks and versions again
2) Gather all disk locations for documents in the chunk
3) Sort documents, to improve speed of cloning
4) Start copying documents from donor to receiver
Phase4 - Transfer chunk
1) Start a loop with 24 hour TTL
a) Verify lock is still active
b) sleeps between runs ( time grow over iteration counts)
c) Check status of chunk copy
d) Check memory used for migrations, error >500MB

!
Phase 5 - Lock, log & update
1) Increase MetaVersions
2) Check config server status
1) If good, update config map for chunks
2) If not, rollback config and copied chunk
3) Commit changes to config server, update mongos
Phase 6 - Clean up
1) Check if _waitfordelete usage
A. added in 2.4 to not block on deletes
2) If false, Queue deletes and mark complete
3) Otherwise start deleteNow , regardless of successful
delete return true
4) Mark Phase 6 complete in config.changelog
What is an orphan, and why do I care?
Orphan document - Any document that exists in a mongod,
but the config map does not reference.
How the happen? - Anytime a balancer fails to fully clean up
a chunk orphans can be left. The are very difficult to detect
outside odd counts noticed by users/application code.

No Solutions for orphans, however 10Gen Mongo 2.6+ will have new commands to help
clean up orphans
ObjectRocket Utilities - https://github.com/objectrocket/Utils
Balanced chunks…non-balanced disk?
What does balanced mean?

•
•

ObjectRocket -

Even distribution of documents or disk space

MongoDB Inc -

Even distribution of chunk (ranges of documents)

counts

!
Deal with balancing on spaces
1. Find large chunks using “datasize” command
2. Use “split” command to split the chunks

ObjectRocket Utilities - https://github.com/objectrocket/Utils
Contact
@dmurphy_data
@objectrocket
david@objectrocket.com
https://www.objectrocket.com

!

WE ARE HIRING! (DBA,DEVOPS, and more)
https://www.objectrocket.com/careers

Contenu connexe

En vedette

China midwestern cement industry production and marketing demand and investme...
China midwestern cement industry production and marketing demand and investme...China midwestern cement industry production and marketing demand and investme...
China midwestern cement industry production and marketing demand and investme...Qianzhan Intelligence
 
China electric power construction industry market forecast and investment str...
China electric power construction industry market forecast and investment str...China electric power construction industry market forecast and investment str...
China electric power construction industry market forecast and investment str...Qianzhan Intelligence
 
China coal industry development trend and investment strategic decision repor...
China coal industry development trend and investment strategic decision repor...China coal industry development trend and investment strategic decision repor...
China coal industry development trend and investment strategic decision repor...Qianzhan Intelligence
 
China rfid industry market forecast and investment strategy planning report, ...
China rfid industry market forecast and investment strategy planning report, ...China rfid industry market forecast and investment strategy planning report, ...
China rfid industry market forecast and investment strategy planning report, ...Qianzhan Intelligence
 
China chemical medicine preparation industry production & marketing demand an...
China chemical medicine preparation industry production & marketing demand an...China chemical medicine preparation industry production & marketing demand an...
China chemical medicine preparation industry production & marketing demand an...Qianzhan Intelligence
 
China luxury industry market demand and investment forecast report, 2013 2017
China luxury industry market demand and investment forecast report, 2013 2017China luxury industry market demand and investment forecast report, 2013 2017
China luxury industry market demand and investment forecast report, 2013 2017Qianzhan Intelligence
 
China luxury industry market demand and investment forecast report, 2013 2017
China luxury industry market demand and investment forecast report, 2013 2017China luxury industry market demand and investment forecast report, 2013 2017
China luxury industry market demand and investment forecast report, 2013 2017Qianzhan Intelligence
 
Showtime at the Apollo - Powerpoint
Showtime at the Apollo - PowerpointShowtime at the Apollo - Powerpoint
Showtime at the Apollo - PowerpointBillionaireBetty
 
China industrial gas industry market forecast and investment strategic planni...
China industrial gas industry market forecast and investment strategic planni...China industrial gas industry market forecast and investment strategic planni...
China industrial gas industry market forecast and investment strategic planni...Qianzhan Intelligence
 
Social media advertising
Social media advertisingSocial media advertising
Social media advertisingVijay Shankar
 
China industrial gas industry market forecast and investment strategic planni...
China industrial gas industry market forecast and investment strategic planni...China industrial gas industry market forecast and investment strategic planni...
China industrial gas industry market forecast and investment strategic planni...Qianzhan Intelligence
 
Sharding why,what,when, how
Sharding   why,what,when, howSharding   why,what,when, how
Sharding why,what,when, howDavid Murphy
 

En vedette (12)

China midwestern cement industry production and marketing demand and investme...
China midwestern cement industry production and marketing demand and investme...China midwestern cement industry production and marketing demand and investme...
China midwestern cement industry production and marketing demand and investme...
 
China electric power construction industry market forecast and investment str...
China electric power construction industry market forecast and investment str...China electric power construction industry market forecast and investment str...
China electric power construction industry market forecast and investment str...
 
China coal industry development trend and investment strategic decision repor...
China coal industry development trend and investment strategic decision repor...China coal industry development trend and investment strategic decision repor...
China coal industry development trend and investment strategic decision repor...
 
China rfid industry market forecast and investment strategy planning report, ...
China rfid industry market forecast and investment strategy planning report, ...China rfid industry market forecast and investment strategy planning report, ...
China rfid industry market forecast and investment strategy planning report, ...
 
China chemical medicine preparation industry production & marketing demand an...
China chemical medicine preparation industry production & marketing demand an...China chemical medicine preparation industry production & marketing demand an...
China chemical medicine preparation industry production & marketing demand an...
 
China luxury industry market demand and investment forecast report, 2013 2017
China luxury industry market demand and investment forecast report, 2013 2017China luxury industry market demand and investment forecast report, 2013 2017
China luxury industry market demand and investment forecast report, 2013 2017
 
China luxury industry market demand and investment forecast report, 2013 2017
China luxury industry market demand and investment forecast report, 2013 2017China luxury industry market demand and investment forecast report, 2013 2017
China luxury industry market demand and investment forecast report, 2013 2017
 
Showtime at the Apollo - Powerpoint
Showtime at the Apollo - PowerpointShowtime at the Apollo - Powerpoint
Showtime at the Apollo - Powerpoint
 
China industrial gas industry market forecast and investment strategic planni...
China industrial gas industry market forecast and investment strategic planni...China industrial gas industry market forecast and investment strategic planni...
China industrial gas industry market forecast and investment strategic planni...
 
Social media advertising
Social media advertisingSocial media advertising
Social media advertising
 
China industrial gas industry market forecast and investment strategic planni...
China industrial gas industry market forecast and investment strategic planni...China industrial gas industry market forecast and investment strategic planni...
China industrial gas industry market forecast and investment strategic planni...
 
Sharding why,what,when, how
Sharding   why,what,when, howSharding   why,what,when, how
Sharding why,what,when, how
 

Dernier

Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Principled Technologies
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024The Digital Insurer
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesBoston Institute of Analytics
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 

Dernier (20)

Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 

October 2013 Austin Mongo DB Meet Up - All about the Cluster Balancer

  • 1. All about the Cluster Balancer in MongoDB MongoDB Meetup Oct 2013 David Murphy DBA, ObjectRocket @dmurphy_data @objectrocket
  • 2. Overview 1)What is sharding? 2)What does the balancer do? 3)Migration phases 4)What is an orphan, and why do I care? 5)Balanced chunks, but not disk space? What can you do? !
  • 3. What is sharding? Definition A method to horizontally scale out software/database layers Key terms ! Shard Replication Set Chunk Balancer Config Server Mongos A specific replication set part of a larger cluster Set of mongod servers setup as “Primary’s” and “Secondary's” Logical unit of documents used for moving data between shards Process on mongos that ensures even chunk counts over shards Stores metadata used by mongos Central router for queries to mongo shards Why? Needed to enable the linear scalability part to the mongo stack. Servers have limited resources, enables using more servers to get more resources.
  • 4. What does the Cluster Balancer do? Does: Does not: Manage chunk count balance Split chunks Clone chunks Merge chunk Apply oplog to clones Balance disk space Remove duplicate documents Remove orphans documents
  • 5. Phase of a chunk migration 1.Parse arguments and prepare 2.Check config and lock 3.Find documents on donor and sort 4.Copy the chunk to destination shard 5.Global lock, log change, update config 6.Clean up and unlock
  • 6. Phase1 - Parse and prepare 1) Check if cluster is running healthy and majority 2) Ensure running in replset not master/slave 3) Ensure collection is replicated 4) Collect metadata for later phases !
  • 7. Phase2 - Check and lock 1)Check for active migration lock 2) Take distributed lock 3) Log event to “config.changelog” 4) Do final check of chunk boundaries and owning shard 5) Validate mongod versions match !
  • 8. Phase3 - Find and sort 1) Check locks and versions again 2) Gather all disk locations for documents in the chunk 3) Sort documents, to improve speed of cloning 4) Start copying documents from donor to receiver
  • 9. Phase4 - Transfer chunk 1) Start a loop with 24 hour TTL a) Verify lock is still active b) sleeps between runs ( time grow over iteration counts) c) Check status of chunk copy d) Check memory used for migrations, error >500MB !
  • 10. Phase 5 - Lock, log & update 1) Increase MetaVersions 2) Check config server status 1) If good, update config map for chunks 2) If not, rollback config and copied chunk 3) Commit changes to config server, update mongos
  • 11. Phase 6 - Clean up 1) Check if _waitfordelete usage A. added in 2.4 to not block on deletes 2) If false, Queue deletes and mark complete 3) Otherwise start deleteNow , regardless of successful delete return true 4) Mark Phase 6 complete in config.changelog
  • 12. What is an orphan, and why do I care? Orphan document - Any document that exists in a mongod, but the config map does not reference. How the happen? - Anytime a balancer fails to fully clean up a chunk orphans can be left. The are very difficult to detect outside odd counts noticed by users/application code. No Solutions for orphans, however 10Gen Mongo 2.6+ will have new commands to help clean up orphans ObjectRocket Utilities - https://github.com/objectrocket/Utils
  • 13. Balanced chunks…non-balanced disk? What does balanced mean? • • ObjectRocket - Even distribution of documents or disk space MongoDB Inc - Even distribution of chunk (ranges of documents) counts ! Deal with balancing on spaces 1. Find large chunks using “datasize” command 2. Use “split” command to split the chunks ObjectRocket Utilities - https://github.com/objectrocket/Utils