webinar: right and wrong ways to implement mongodb
DESCRIPTION
MongoDB offers users a great deal of flexibility vis-a-vis implementation decisions, and this flexibility brings a lot of power. But with great power comes great responsibility. In this talk we'll cover some better and worse implementation options, including deployment topologies, capacity provisioning, data loading, and more!TRANSCRIPT
![Page 1: Webinar: Right and Wrong Ways to Implement MongoDB](https://reader033.vdocuments.site/reader033/viewer/2022051412/54b73ede4a7959be4c8b4874/html5/thumbnails/1.jpg)
Consulting Manager, 10gen
Richard Kreuter
Right Ways and Wrong Ways to Implement MongoDB
![Page 2: Webinar: Right and Wrong Ways to Implement MongoDB](https://reader033.vdocuments.site/reader033/viewer/2022051412/54b73ede4a7959be4c8b4874/html5/thumbnails/2.jpg)
Right Ways, Wrong Ways – Richard Kreuter
This talk
• MongoDB is flexible.
• 3 areas where folks make mistakes
• Things you should remember
![Page 3: Webinar: Right and Wrong Ways to Implement MongoDB](https://reader033.vdocuments.site/reader033/viewer/2022051412/54b73ede4a7959be4c8b4874/html5/thumbnails/3.jpg)
Flexibility
![Page 4: Webinar: Right and Wrong Ways to Implement MongoDB](https://reader033.vdocuments.site/reader033/viewer/2022051412/54b73ede4a7959be4c8b4874/html5/thumbnails/4.jpg)
Right Ways, Wrong Ways – Richard Kreuter
MongoDB is very flexible
• Designed for cloud, commodity– Portable across OS, hardware, network
• HA/DR/Scaling options built-in– Replication: “How many copies of data?”– Sharding: “How are data & load distributed?”
• Many dimensions of choices– How many servers? Where? What hardware?
![Page 5: Webinar: Right and Wrong Ways to Implement MongoDB](https://reader033.vdocuments.site/reader033/viewer/2022051412/54b73ede4a7959be4c8b4874/html5/thumbnails/5.jpg)
Right Ways, Wrong Ways – Richard Kreuter
These choices give you power
• Can provision for different fault tolerances• Can configure system to scale horizontally• Can use features for special requirements
(e.g., geographical distribution)
![Page 6: Webinar: Right and Wrong Ways to Implement MongoDB](https://reader033.vdocuments.site/reader033/viewer/2022051412/54b73ede4a7959be4c8b4874/html5/thumbnails/6.jpg)
Right Ways, Wrong Ways – Richard Kreuter
With great power comes great responsibility1
• Some choices nonsensical 99% of the time
• (Contrived exceptions should be ignored.)
1: Stan Lee, author of Spider-Man
![Page 7: Webinar: Right and Wrong Ways to Implement MongoDB](https://reader033.vdocuments.site/reader033/viewer/2022051412/54b73ede4a7959be4c8b4874/html5/thumbnails/7.jpg)
Right Ways, Wrong Ways – Richard Kreuter
Meta Rule of Thumb
To make good decisions about MongoDB implementations, you must understand MongoDB and your applications and the
workload your applications generate and your business requirements.
![Page 8: Webinar: Right and Wrong Ways to Implement MongoDB](https://reader033.vdocuments.site/reader033/viewer/2022051412/54b73ede4a7959be4c8b4874/html5/thumbnails/8.jpg)
Deployment Topologies
![Page 9: Webinar: Right and Wrong Ways to Implement MongoDB](https://reader033.vdocuments.site/reader033/viewer/2022051412/54b73ede4a7959be4c8b4874/html5/thumbnails/9.jpg)
Right Ways, Wrong Ways – Richard Kreuter
Replication Topology Mistakes
• All replica set members on one host
• Replica set members sharing same storage
• Replica set evenly split across 2 DCs– (Actually, two is a bad number for replica sets.)
![Page 10: Webinar: Right and Wrong Ways to Implement MongoDB](https://reader033.vdocuments.site/reader033/viewer/2022051412/54b73ede4a7959be4c8b4874/html5/thumbnails/10.jpg)
Right Ways, Wrong Ways – Richard Kreuter
Replica Set Rule of Thumb:Decouple all modes of failure!
![Page 11: Webinar: Right and Wrong Ways to Implement MongoDB](https://reader033.vdocuments.site/reader033/viewer/2022051412/54b73ede4a7959be4c8b4874/html5/thumbnails/11.jpg)
Right Ways, Wrong Ways – Richard Kreuter
Replication Topology Fixes
• All replica set members on one host– Put replicas on different hosts
• Replica set members sharing same storage– Give each replica separate storage
• Replica set evenly split across 2 DCs– Use more DCs– Understand RS elections
![Page 12: Webinar: Right and Wrong Ways to Implement MongoDB](https://reader033.vdocuments.site/reader033/viewer/2022051412/54b73ede4a7959be4c8b4874/html5/thumbnails/12.jpg)
Right Ways, Wrong Ways – Richard Kreuter
Some Sharding Topology Mistakes
• Shards that aren’t Replica Sets
• Solitary config server
![Page 13: Webinar: Right and Wrong Ways to Implement MongoDB](https://reader033.vdocuments.site/reader033/viewer/2022051412/54b73ede4a7959be4c8b4874/html5/thumbnails/13.jpg)
Right Ways, Wrong Ways – Richard Kreuter
Sharding Rule of Thumb #1:Avoid single points of failure!
![Page 14: Webinar: Right and Wrong Ways to Implement MongoDB](https://reader033.vdocuments.site/reader033/viewer/2022051412/54b73ede4a7959be4c8b4874/html5/thumbnails/14.jpg)
Right Ways, Wrong Ways – Richard Kreuter
Some Sharding Topology Fixes
• Shards that aren’t Replica Sets– Each shard should be a replica set
• Solitary config server– Always use 3 config servers
![Page 15: Webinar: Right and Wrong Ways to Implement MongoDB](https://reader033.vdocuments.site/reader033/viewer/2022051412/54b73ede4a7959be4c8b4874/html5/thumbnails/15.jpg)
Right Ways, Wrong Ways – Richard Kreuter
More Sharding Topology Mistakes
• Multiple shards on one box
• One/too few mongos processes
![Page 16: Webinar: Right and Wrong Ways to Implement MongoDB](https://reader033.vdocuments.site/reader033/viewer/2022051412/54b73ede4a7959be4c8b4874/html5/thumbnails/16.jpg)
Right Ways, Wrong Ways – Richard Kreuter
Sharding Rule of Thumb #2:Add unshared resources for scaling!
![Page 17: Webinar: Right and Wrong Ways to Implement MongoDB](https://reader033.vdocuments.site/reader033/viewer/2022051412/54b73ede4a7959be4c8b4874/html5/thumbnails/17.jpg)
Right Ways, Wrong Ways – Richard Kreuter
More Sharding Topology Fixes
• Multiple shards on one box– Shards should never share hardware.
• One/too few mongos processes– Run more mongos processes – (1+ per app server, say)
![Page 18: Webinar: Right and Wrong Ways to Implement MongoDB](https://reader033.vdocuments.site/reader033/viewer/2022051412/54b73ede4a7959be4c8b4874/html5/thumbnails/18.jpg)
Performance Considerations
![Page 19: Webinar: Right and Wrong Ways to Implement MongoDB](https://reader033.vdocuments.site/reader033/viewer/2022051412/54b73ede4a7959be4c8b4874/html5/thumbnails/19.jpg)
Right Ways, Wrong Ways – Richard Kreuter
Indexing Mistakes
• Failing to build necessary indexes
• Building unnecessary indexes
• Running ad-hoc queries in production
![Page 20: Webinar: Right and Wrong Ways to Implement MongoDB](https://reader033.vdocuments.site/reader033/viewer/2022051412/54b73ede4a7959be4c8b4874/html5/thumbnails/20.jpg)
Right Ways, Wrong Ways – Richard Kreuter
Indexing Rule of Thumb:Build all and only necessary indexes!
![Page 21: Webinar: Right and Wrong Ways to Implement MongoDB](https://reader033.vdocuments.site/reader033/viewer/2022051412/54b73ede4a7959be4c8b4874/html5/thumbnails/21.jpg)
Right Ways, Wrong Ways – Richard Kreuter
Indexing Fixes
• Failing to build necessary indexes– Learn to use the slow query log & db profiler
• Building unnecessary indexes– Talk to your app developers about usage
• Running ad-hoc queries in production- Have a staging environment, use secondaries
![Page 22: Webinar: Right and Wrong Ways to Implement MongoDB](https://reader033.vdocuments.site/reader033/viewer/2022051412/54b73ede4a7959be4c8b4874/html5/thumbnails/22.jpg)
Right Ways, Wrong Ways – Richard Kreuter
Shard Key Selection Mistakes
• Shard key that’s never used
• Low cardinality shard key
• Picking a shard key for initial import, not regular usage
![Page 23: Webinar: Right and Wrong Ways to Implement MongoDB](https://reader033.vdocuments.site/reader033/viewer/2022051412/54b73ede4a7959be4c8b4874/html5/thumbnails/23.jpg)
Right Ways, Wrong Ways – Richard Kreuter
Shard Key Rule of Thumb:Choose shard keys carefully!
![Page 24: Webinar: Right and Wrong Ways to Implement MongoDB](https://reader033.vdocuments.site/reader033/viewer/2022051412/54b73ede4a7959be4c8b4874/html5/thumbnails/24.jpg)
Right Ways, Wrong Ways – Richard Kreuter
Shard Key Selection Fixes
• Shard key that’s never used– Understand your query/update patterns
• Low cardinality shard key– Find a higher cardinality option (or just concatenate the
_id field)
• Picking a shard key for initial import, not regular usage– Find other ways to make initial import fast
![Page 25: Webinar: Right and Wrong Ways to Implement MongoDB](https://reader033.vdocuments.site/reader033/viewer/2022051412/54b73ede4a7959be4c8b4874/html5/thumbnails/25.jpg)
Hardware Choices
![Page 26: Webinar: Right and Wrong Ways to Implement MongoDB](https://reader033.vdocuments.site/reader033/viewer/2022051412/54b73ede4a7959be4c8b4874/html5/thumbnails/26.jpg)
Right Ways, Wrong Ways – Richard Kreuter
Hardware Selection Mistakes
• Skimping on RAM
• Skimping on disk speeds
![Page 27: Webinar: Right and Wrong Ways to Implement MongoDB](https://reader033.vdocuments.site/reader033/viewer/2022051412/54b73ede4a7959be4c8b4874/html5/thumbnails/27.jpg)
Right Ways, Wrong Ways – Richard Kreuter
Hardware Rule of Thumb #1:Choose your hardware with your use of MongoDB’s architecture in mind!
![Page 28: Webinar: Right and Wrong Ways to Implement MongoDB](https://reader033.vdocuments.site/reader033/viewer/2022051412/54b73ede4a7959be4c8b4874/html5/thumbnails/28.jpg)
Right Ways, Wrong Ways – Richard Kreuter
Hardware Selection Fixes
• Skimping on RAM– Understand/estimate your Working Set
• Skimping on disk speeds– Understand/estimate your write load
![Page 29: Webinar: Right and Wrong Ways to Implement MongoDB](https://reader033.vdocuments.site/reader033/viewer/2022051412/54b73ede4a7959be4c8b4874/html5/thumbnails/29.jpg)
Right Ways, Wrong Ways – Richard Kreuter
Hardware Selection Oddities
• (Re-)Provisioning hardware intended for other systems
• Not controlling virtual machine locations
![Page 30: Webinar: Right and Wrong Ways to Implement MongoDB](https://reader033.vdocuments.site/reader033/viewer/2022051412/54b73ede4a7959be4c8b4874/html5/thumbnails/30.jpg)
Right Ways, Wrong Ways – Richard Kreuter
Hardware Rule of Thumb #2:Pick hardware/virtualization that serves your use of MongoDB!
![Page 31: Webinar: Right and Wrong Ways to Implement MongoDB](https://reader033.vdocuments.site/reader033/viewer/2022051412/54b73ede4a7959be4c8b4874/html5/thumbnails/31.jpg)
Right Ways, Wrong Ways – Richard Kreuter
Hardware Selection Fixes
• (Re-)Provisioning hardware intended for other systems• Understand how MongoDB uses hardware
• Not controlling virtual machine locations• Be sure you can control where VMs run
![Page 32: Webinar: Right and Wrong Ways to Implement MongoDB](https://reader033.vdocuments.site/reader033/viewer/2022051412/54b73ede4a7959be4c8b4874/html5/thumbnails/32.jpg)
Things to remember!
![Page 33: Webinar: Right and Wrong Ways to Implement MongoDB](https://reader033.vdocuments.site/reader033/viewer/2022051412/54b73ede4a7959be4c8b4874/html5/thumbnails/33.jpg)
Right Ways, Wrong Ways – Richard Kreuter
In Conclusion…• Learn how MongoDB works.
• Do know what your technical & business requirements are.
• Work backwards from requirements to choices.
• Don’t make MongoDB choices based on legacy habits/practices
• Expect that things will change.
• Ask 10gen to Help!
![Page 34: Webinar: Right and Wrong Ways to Implement MongoDB](https://reader033.vdocuments.site/reader033/viewer/2022051412/54b73ede4a7959be4c8b4874/html5/thumbnails/34.jpg)
Consulting Manager, 10gen
Richard Kreuter
Thank you!