SlideShare a Scribd company logo
1 of 33
Download to read offline
Evolution of MongoDB Sharding and Its Best Practices
Presenter by
Ranjith A
Database Engineer @ Mydbops
Mydbops 11th Webinar
www.mydbops.com info@mydbops.com
Ranjith A
MongoDB Database Engineer
ranjith@mydbops.com
linkedin.com/in/ranjith-a-70aab0157
About Me
Mydbops at a Glance
● Founded in 2015, HQ in Bangalore India, 70+ Employees.
● Mydbops is on Database Consulting with core specialization on MySQL, MongoDB and PostgreSQL
Administration and Support.
● Mydbops was created with a motto of developing a DevOPS model for Database Administration.
● We help organisations to scale in MySQL/Mongodb/postgresql and implement the advanced technologies in
MySQL/Mongodb/PostgreSQL.
Mydbops at a Glance
Happy Customers
4
Agenda
● Intro
● Sharding Overview
● Sharding Architecture
● Types of Sharding
● Things need to be taken care before choosing shard key
● Evolution of sharding from 3.6 to 5.0
● Q/A
Intro
Sharding Overview
● Sharding is a method for distributing data across multiple machines.
● By using MongoDB sharding, We can handle very large data sets and high throughput operations.
● Database systems with large data sets or high throughput applications can challenge the capacity of a single server.
● For example, If our system is a heavy read sensitive it will exhaust the CPU capacity of the server. Working set sizes
larger than the system's RAM stress the I/O capacity of disk drives.
Sharding Overview
We can scale the system in two engineering approach.
Vertical Scaling Horizontal sharding
Achieved by MongoDB replica set / standalone server Achieved by MongoDB Sharding
Data set in Single server Distribute the data set to Multiple servers
Increasing the server capacity of a single server. Adding additional servers to increase capacity as required.
There is a limitation for increasing the server capacity We can easily add or remove additional servers as required.
Sharding Architecture
Sharding Architecture - (Data Shard)
● MongoDB supports horizontal scaling through MongoDB Sharded Cluster.
● MongoDB shards data at the collection level, distributing the collection data across the shards in the cluster.
● MongoDB Sharded Cluster consists of the following components:
1. Shards
2. Mongos
3. Config server
Shard:
● Each shard contains a subset of the sharded data.
● Each shard can be deployed as a replica set.
Sharding Architecture-(Mongos)
Mongos:
● The mongos acts as a query router, providing an interface between client applications and the sharded cluster.
● Applications never connect or communicate directly with the shards.
● The mongos tracks what data is on which shard by caching the metadata from the config servers.
● The mongos uses the metadata to route operations from applications and clients to the mongod instances.
● The mongos receives responses from all shards, it merges the data and returns the result document.
Sharding Architecture-(Config)
Config Server:
● Config servers store metadata and configuration settings for the cluster. As of MongoDB 3.4, config servers must
be deployed as a replica set (CSRS).
● If your cluster has a single config server, then the config server is a single point of failure.
● If the config server is inaccessible, the cluster is not accessible.
● If you cannot recover the data on a config server, the cluster will be inoperable.
● Always use three config servers for production deployments
Types of Sharding-(Hashed Sharding)
MongoDB supports two sharding methods for distributing data across sharded clusters.
● Hashed sharding
● Ranged Sharding
Hashed sharding:
Hashed sharding
● Hashed Sharding involves computing a hash of the shard key field's value. We can use either a single field hashed index
or a compound hashed index (New in 4.4) as the shard key.
● MongoDB automatically computes the hashes when resolving queries using hashed indexes.
● Hashed sharding provides a more even data distribution across the sharded cluster.
● The fields which we chose the hashed shard key should have a good cardinality (more unique values).
● Default _id field is the best example for good cardinality (Objectid values).
Hashed sharding
Command to enable Sharding: (DB Level)
sh.enableSharding("databasename")
Hashed sharding
Command to enable Sharding: (Collection Level)
sh.shardCollection( "databasename.collectionname", { "field" : "hashed" } )
● Make sure before enabling sharding for a particular collection database must be sharded also the Index must be
available for the fields which we are going to use as a shard key.
Ranged sharding
Ranged sharding:
Ranged sharding
● In Range-based sharding, data's are splitted into contiguous ranges determined by the shard key values.
● Data with "close" shard key values are likely to be in the same chunk or shard.
● This will improve the performance of the read queries (target documents) within a contiguous range.
● Poor sharded key selection will affect both read and write performance.
Command to enable Sharding: (Collection Level)
sh.shardCollection( "databasename.collectionname", { "field" : 1 } )
● Make sure before enabling sharding for a particular collection, database must be sharded also the Index must be
available for the fields which we are going to use as a shard key.
Zone sharding
● In sharded clusters, you can create single or multiple zones in single shard as well as multiple shards.
● Zones represent a group of shards and associate one or more ranges of shard key values to that zone.
● Zone ranges are always inclusive of the lower boundary and exclusive of the upper boundary.
● From MongoDB 4.0.2, dropping a collection deletes its associated zone/tag ranges.
● Zones information are stored in config.shards & config.tags collection
● Starting from MongoDB 4.4 brings we can shard a collection and determine zones by compound keys, including
mixing a hashed key with non-hashed keys.
Zone sharding
Command to create Zone:
sh.addShardToZone("shardname", "zonename")
Zone sharding
Command to create Zone range:
sh.updateZoneKeyRange("dbname.collectionname", { fieldname: "minkey" }, { fieldname: "maxkey" },
"zonename")
Sharded key
Shard key is the key to evenly distribute the data among all shards. Good shared key always satisfies the below points.
● High Cardinality
● High Frequency
● Non Monotonically Changing Shard Keys
● Sharding Query patterns
Sharded key
High Cardinality:
● High cardinality shard key - More no. of chunks & evenly distributed data
● Low cardinality shard key - Less no. of chunks & low distributed data
● Each unique shard key value can exist on no more than a single chunk at any given time.
High Frequency:
● High frequency shard key - More evenly distributed data
● Low frequency shard key - Low distributed data
● Shard key cardinality & monotonically changing shard key also contribute to the distribution of the data.
Sharded key
Non Monotonically Changing Shard Keys:-
● monotonically increases or decreases shard key tends to distribute the data to a single chunk within the cluster.
● Each chunk has its own min & Max value.
Evolution of sharding from 3.6 to 5.0
Mongo
version
Modify shard
key field value
Refining
shard key
Change
shard key
New variables New features
3.6 NO NO NO orphanCleanupDelaySecs Shard must be a replica set
All shard members have chunk
metadata
4.2 YES NO NO sh.setBalancerState(true)
sh.setBalancerState(false)
Modify shard key field value except
immutable _id field
4.4 YES YES NO Hedged Reads Refinable shard keys
Hedged Reads
compound shard keys with a hashed
field
Remove multiple shard at a time
Remove shard key size limit
5.0 YES YES YES reshardCollection Change the shard key
Change the name of a sharded
collection
Sharding Features in 3.6
● Shards must be replica sets.
● All members of the shard replica set maintain the metadata regarding chunk metadata. This prevents reads from
the secondaries from returning orphaned data.
● Based on the orphanCleanupDelaySecs (New in 3.6) variable migrated chunk is deleted from the source shard.
● orphanCleanupDelaySecs - Default 900 (15 min)
Set the orphanCleanupDelaySecs value to 20 min during the mongo service start
mongod --setParameter orphanCleanupDelaySecs=1200 (20 min)
setParameter command:
db.adminCommand( { setParameter: 1, orphanCleanupDelaySecs: 1200 } )
Sharding Features in 4.2
● We can update a document's shard key value except the shard key field is the immutable _id field.
● In earlier version we can't change the document's shard key value.
Sharding Features in 4.2
New variables in 4.2:
● sh.startBalancer() - sh.setBalancerState(true) (Enable auto-splitting for the sharded cluster)
● sh.stopBalancer() - sh.setBalancerState(false) (Disable auto-splitting for the sharded cluster)
● sh.enableAutoSplit() - Enable auto-splitting when the balancer is disabled
Sharding Features in 4.4
● Refinable Shard Keys - refine a collection's shard key by adding a suffix field or fields to the existing key
db.employee.createIndex({"employeeid" : 1, "mailid": 1})
db.adminCommand( {refineCollectionShardKey: "mydbops.employee",
key: { "employeeid" : 1, "mailid": 1 }} )
● In 4.4, Shard key field can be missing in a sharded collection.
● In earlier versions, shard key fields must exist in every document for a sharded collection.
● Support Hedged Reads - To minimize latencies
● Support compound shard keys with a hashed field.
● More than one removeShard operation at a time.
● MongoDB removes the 512-byte limit on the shard key size.
Sharding Features in 5.0
● We have a option to change the shard key by using reshardCollection command.
● To change the name of a sharded collection by using renameCollection command.
Things need to be taken care before resharding:
● Initially MongoDB block writes to two seconds and begins the resharding operation.
● Available space should be 1.2x the size of the collection that you want to reshard.
● Ensure the Disk (50%) & CPU (80%) utilisation will be minimal.
● The new shard key cannot have a uniqueness constraint
● If a collection having uniqueness constraint is not supported for Resharding
Sharding Features in 5.0
The following commands are not supported on the collection, while the resharding operation is in progress.
● collMod
● convertToCapped
● createIndexes
● createIndex()
● drop()
● dropIndexes
● dropIndex()
● renameCollection
● renameCollection()
Sharding Features in 5.0
The following methods are not supported on the cluster, while the resharding operation is in progress.
● addShard
● removeShard
● db.createCollection()
● dropDatabase
Resharded commands:
● db.adminCommand({ reshardCollection: "mydbops.client", key: {"cperiod": 1} } )
Evolution of MonogDB Sharding and Its Best Practices - Ranjith A - Mydbops Team

More Related Content

What's hot

Basic Sharding in MongoDB presented by Shaun Verch
Basic Sharding in MongoDB presented by Shaun VerchBasic Sharding in MongoDB presented by Shaun Verch
Basic Sharding in MongoDB presented by Shaun VerchMongoDB
 
Sharding
ShardingSharding
ShardingMongoDB
 
Scaling with MongoDB
Scaling with MongoDBScaling with MongoDB
Scaling with MongoDBRick Copeland
 
MongoDB San Francisco 2013: Basic Sharding in MongoDB presented by Brandon Bl...
MongoDB San Francisco 2013: Basic Sharding in MongoDB presented by Brandon Bl...MongoDB San Francisco 2013: Basic Sharding in MongoDB presented by Brandon Bl...
MongoDB San Francisco 2013: Basic Sharding in MongoDB presented by Brandon Bl...MongoDB
 
Mongodb sharding
Mongodb shardingMongodb sharding
Mongodb shardingxiangrong
 
Sharding Methods for MongoDB
Sharding Methods for MongoDBSharding Methods for MongoDB
Sharding Methods for MongoDBMongoDB
 
NoSQL Analytics: JSON Data Analysis and Acceleration in MongoDB World
NoSQL Analytics: JSON Data Analysis and Acceleration in MongoDB WorldNoSQL Analytics: JSON Data Analysis and Acceleration in MongoDB World
NoSQL Analytics: JSON Data Analysis and Acceleration in MongoDB WorldAjay Gupte
 
Mongodb - Scaling write performance
Mongodb - Scaling write performanceMongodb - Scaling write performance
Mongodb - Scaling write performanceDaum DNA
 
2014 05-07-fr - add dev series - session 6 - deploying your application-2
2014 05-07-fr - add dev series - session 6 - deploying your application-22014 05-07-fr - add dev series - session 6 - deploying your application-2
2014 05-07-fr - add dev series - session 6 - deploying your application-2MongoDB
 
MongoDB Best Practices in AWS
MongoDB Best Practices in AWS MongoDB Best Practices in AWS
MongoDB Best Practices in AWS Chris Harris
 
Development to Production with Sharded MongoDB Clusters
Development to Production with Sharded MongoDB ClustersDevelopment to Production with Sharded MongoDB Clusters
Development to Production with Sharded MongoDB ClustersSeveralnines
 
Sharding - Seoul 2012
Sharding - Seoul 2012Sharding - Seoul 2012
Sharding - Seoul 2012MongoDB
 
Replication and replica sets
Replication and replica setsReplication and replica sets
Replication and replica setsRandall Hunt
 
Sharding
ShardingSharding
ShardingMongoDB
 
MongoDB at Scale
MongoDB at ScaleMongoDB at Scale
MongoDB at ScaleMongoDB
 
Sharding
ShardingSharding
ShardingMongoDB
 
Everything You Need to Know About Sharding
Everything You Need to Know About ShardingEverything You Need to Know About Sharding
Everything You Need to Know About ShardingMongoDB
 
Webinar: Performance Tuning + Optimization
Webinar: Performance Tuning + OptimizationWebinar: Performance Tuning + Optimization
Webinar: Performance Tuning + OptimizationMongoDB
 
Setting up mongodb sharded cluster in 30 minutes
Setting up mongodb sharded cluster in 30 minutesSetting up mongodb sharded cluster in 30 minutes
Setting up mongodb sharded cluster in 30 minutesSudheer Kondla
 

What's hot (20)

Basic Sharding in MongoDB presented by Shaun Verch
Basic Sharding in MongoDB presented by Shaun VerchBasic Sharding in MongoDB presented by Shaun Verch
Basic Sharding in MongoDB presented by Shaun Verch
 
Sharding
ShardingSharding
Sharding
 
Scaling with MongoDB
Scaling with MongoDBScaling with MongoDB
Scaling with MongoDB
 
MongoDB San Francisco 2013: Basic Sharding in MongoDB presented by Brandon Bl...
MongoDB San Francisco 2013: Basic Sharding in MongoDB presented by Brandon Bl...MongoDB San Francisco 2013: Basic Sharding in MongoDB presented by Brandon Bl...
MongoDB San Francisco 2013: Basic Sharding in MongoDB presented by Brandon Bl...
 
Mongodb sharding
Mongodb shardingMongodb sharding
Mongodb sharding
 
Sharding Methods for MongoDB
Sharding Methods for MongoDBSharding Methods for MongoDB
Sharding Methods for MongoDB
 
NoSQL Analytics: JSON Data Analysis and Acceleration in MongoDB World
NoSQL Analytics: JSON Data Analysis and Acceleration in MongoDB WorldNoSQL Analytics: JSON Data Analysis and Acceleration in MongoDB World
NoSQL Analytics: JSON Data Analysis and Acceleration in MongoDB World
 
Mongodb - Scaling write performance
Mongodb - Scaling write performanceMongodb - Scaling write performance
Mongodb - Scaling write performance
 
MongoDB Sharding Fundamentals
MongoDB Sharding Fundamentals MongoDB Sharding Fundamentals
MongoDB Sharding Fundamentals
 
2014 05-07-fr - add dev series - session 6 - deploying your application-2
2014 05-07-fr - add dev series - session 6 - deploying your application-22014 05-07-fr - add dev series - session 6 - deploying your application-2
2014 05-07-fr - add dev series - session 6 - deploying your application-2
 
MongoDB Best Practices in AWS
MongoDB Best Practices in AWS MongoDB Best Practices in AWS
MongoDB Best Practices in AWS
 
Development to Production with Sharded MongoDB Clusters
Development to Production with Sharded MongoDB ClustersDevelopment to Production with Sharded MongoDB Clusters
Development to Production with Sharded MongoDB Clusters
 
Sharding - Seoul 2012
Sharding - Seoul 2012Sharding - Seoul 2012
Sharding - Seoul 2012
 
Replication and replica sets
Replication and replica setsReplication and replica sets
Replication and replica sets
 
Sharding
ShardingSharding
Sharding
 
MongoDB at Scale
MongoDB at ScaleMongoDB at Scale
MongoDB at Scale
 
Sharding
ShardingSharding
Sharding
 
Everything You Need to Know About Sharding
Everything You Need to Know About ShardingEverything You Need to Know About Sharding
Everything You Need to Know About Sharding
 
Webinar: Performance Tuning + Optimization
Webinar: Performance Tuning + OptimizationWebinar: Performance Tuning + Optimization
Webinar: Performance Tuning + Optimization
 
Setting up mongodb sharded cluster in 30 minutes
Setting up mongodb sharded cluster in 30 minutesSetting up mongodb sharded cluster in 30 minutes
Setting up mongodb sharded cluster in 30 minutes
 

Similar to Evolution of MonogDB Sharding and Its Best Practices - Ranjith A - Mydbops Team

Scaling MongoDB with Horizontal and Vertical Sharding
Scaling MongoDB with Horizontal and Vertical Sharding Scaling MongoDB with Horizontal and Vertical Sharding
Scaling MongoDB with Horizontal and Vertical Sharding Mydbops
 
Scaling-MongoDB-with-Horizontal-and-Vertical-Sharding Mydbops Opensource Data...
Scaling-MongoDB-with-Horizontal-and-Vertical-Sharding Mydbops Opensource Data...Scaling-MongoDB-with-Horizontal-and-Vertical-Sharding Mydbops Opensource Data...
Scaling-MongoDB-with-Horizontal-and-Vertical-Sharding Mydbops Opensource Data...Mydbops
 
MongoDB : Scaling, Security & Performance
MongoDB : Scaling, Security & PerformanceMongoDB : Scaling, Security & Performance
MongoDB : Scaling, Security & PerformanceSasidhar Gogulapati
 
Sharding Overview
Sharding OverviewSharding Overview
Sharding OverviewMongoDB
 
Introduction to Sharding
Introduction to ShardingIntroduction to Sharding
Introduction to ShardingMongoDB
 
Sharding
ShardingSharding
ShardingMongoDB
 
MongoDB: Advance concepts - Replication and Sharding
MongoDB: Advance concepts - Replication and ShardingMongoDB: Advance concepts - Replication and Sharding
MongoDB: Advance concepts - Replication and ShardingKnoldus Inc.
 
DBVersity MongoDB Online Training Presentations
DBVersity MongoDB Online Training PresentationsDBVersity MongoDB Online Training Presentations
DBVersity MongoDB Online Training PresentationsSrinivas Mutyala
 
Advanced Sharding Features in MongoDB 2.4
Advanced Sharding Features in MongoDB 2.4 Advanced Sharding Features in MongoDB 2.4
Advanced Sharding Features in MongoDB 2.4 MongoDB
 
Avoiding Data Hotspots at Scale
Avoiding Data Hotspots at ScaleAvoiding Data Hotspots at Scale
Avoiding Data Hotspots at ScaleScyllaDB
 
What We Need to Unlearn about Persistent Storage
What We Need to Unlearn about Persistent StorageWhat We Need to Unlearn about Persistent Storage
What We Need to Unlearn about Persistent StorageScyllaDB
 
Scaling MongoDB - Presentation at MTP
Scaling MongoDB - Presentation at MTPScaling MongoDB - Presentation at MTP
Scaling MongoDB - Presentation at MTPdarkdata
 
MongoDB Sharding
MongoDB ShardingMongoDB Sharding
MongoDB ShardingRob Walters
 
Sharding in MongoDB Days 2013
Sharding in MongoDB Days 2013Sharding in MongoDB Days 2013
Sharding in MongoDB Days 2013Randall Hunt
 
How sitecore depends on mongo db for scalability and performance, and what it...
How sitecore depends on mongo db for scalability and performance, and what it...How sitecore depends on mongo db for scalability and performance, and what it...
How sitecore depends on mongo db for scalability and performance, and what it...Antonios Giannopoulos
 
MongoDB Europe 2016 - Big Data meets Big Compute
MongoDB Europe 2016 - Big Data meets Big ComputeMongoDB Europe 2016 - Big Data meets Big Compute
MongoDB Europe 2016 - Big Data meets Big ComputeMongoDB
 

Similar to Evolution of MonogDB Sharding and Its Best Practices - Ranjith A - Mydbops Team (20)

Scaling MongoDB with Horizontal and Vertical Sharding
Scaling MongoDB with Horizontal and Vertical Sharding Scaling MongoDB with Horizontal and Vertical Sharding
Scaling MongoDB with Horizontal and Vertical Sharding
 
Scaling-MongoDB-with-Horizontal-and-Vertical-Sharding Mydbops Opensource Data...
Scaling-MongoDB-with-Horizontal-and-Vertical-Sharding Mydbops Opensource Data...Scaling-MongoDB-with-Horizontal-and-Vertical-Sharding Mydbops Opensource Data...
Scaling-MongoDB-with-Horizontal-and-Vertical-Sharding Mydbops Opensource Data...
 
MongoDB : Scaling, Security & Performance
MongoDB : Scaling, Security & PerformanceMongoDB : Scaling, Security & Performance
MongoDB : Scaling, Security & Performance
 
Sharding Overview
Sharding OverviewSharding Overview
Sharding Overview
 
Introduction to Sharding
Introduction to ShardingIntroduction to Sharding
Introduction to Sharding
 
Sharding
ShardingSharding
Sharding
 
MongoDB: Advance concepts - Replication and Sharding
MongoDB: Advance concepts - Replication and ShardingMongoDB: Advance concepts - Replication and Sharding
MongoDB: Advance concepts - Replication and Sharding
 
Tag based sharding presentation
Tag based sharding presentationTag based sharding presentation
Tag based sharding presentation
 
MongoDB
MongoDBMongoDB
MongoDB
 
DBVersity MongoDB Online Training Presentations
DBVersity MongoDB Online Training PresentationsDBVersity MongoDB Online Training Presentations
DBVersity MongoDB Online Training Presentations
 
Advanced Sharding Features in MongoDB 2.4
Advanced Sharding Features in MongoDB 2.4 Advanced Sharding Features in MongoDB 2.4
Advanced Sharding Features in MongoDB 2.4
 
Mongo sharding
Mongo shardingMongo sharding
Mongo sharding
 
Avoiding Data Hotspots at Scale
Avoiding Data Hotspots at ScaleAvoiding Data Hotspots at Scale
Avoiding Data Hotspots at Scale
 
What We Need to Unlearn about Persistent Storage
What We Need to Unlearn about Persistent StorageWhat We Need to Unlearn about Persistent Storage
What We Need to Unlearn about Persistent Storage
 
Mongodb Introduction
Mongodb IntroductionMongodb Introduction
Mongodb Introduction
 
Scaling MongoDB - Presentation at MTP
Scaling MongoDB - Presentation at MTPScaling MongoDB - Presentation at MTP
Scaling MongoDB - Presentation at MTP
 
MongoDB Sharding
MongoDB ShardingMongoDB Sharding
MongoDB Sharding
 
Sharding in MongoDB Days 2013
Sharding in MongoDB Days 2013Sharding in MongoDB Days 2013
Sharding in MongoDB Days 2013
 
How sitecore depends on mongo db for scalability and performance, and what it...
How sitecore depends on mongo db for scalability and performance, and what it...How sitecore depends on mongo db for scalability and performance, and what it...
How sitecore depends on mongo db for scalability and performance, and what it...
 
MongoDB Europe 2016 - Big Data meets Big Compute
MongoDB Europe 2016 - Big Data meets Big ComputeMongoDB Europe 2016 - Big Data meets Big Compute
MongoDB Europe 2016 - Big Data meets Big Compute
 

More from Mydbops

Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterMydbops
 
PostgreSQL Schema Changes with pg-osc - Mydbops @ PGConf India 2024
PostgreSQL Schema Changes with pg-osc - Mydbops @ PGConf India 2024PostgreSQL Schema Changes with pg-osc - Mydbops @ PGConf India 2024
PostgreSQL Schema Changes with pg-osc - Mydbops @ PGConf India 2024Mydbops
 
Choosing the Right Database: Exploring MySQL Alternatives for Modern Applicat...
Choosing the Right Database: Exploring MySQL Alternatives for Modern Applicat...Choosing the Right Database: Exploring MySQL Alternatives for Modern Applicat...
Choosing the Right Database: Exploring MySQL Alternatives for Modern Applicat...Mydbops
 
Mastering Aurora PostgreSQL Clusters for Disaster Recovery
Mastering Aurora PostgreSQL Clusters for Disaster RecoveryMastering Aurora PostgreSQL Clusters for Disaster Recovery
Mastering Aurora PostgreSQL Clusters for Disaster RecoveryMydbops
 
Navigating Transactions: ACID Complexity in Modern Databases- Mydbops Open So...
Navigating Transactions: ACID Complexity in Modern Databases- Mydbops Open So...Navigating Transactions: ACID Complexity in Modern Databases- Mydbops Open So...
Navigating Transactions: ACID Complexity in Modern Databases- Mydbops Open So...Mydbops
 
AWS RDS in MySQL 2023 Vinoth Kanna @ Mydbops OpenSource Database Meetup 15
AWS RDS in MySQL 2023 Vinoth Kanna @ Mydbops OpenSource Database Meetup 15AWS RDS in MySQL 2023 Vinoth Kanna @ Mydbops OpenSource Database Meetup 15
AWS RDS in MySQL 2023 Vinoth Kanna @ Mydbops OpenSource Database Meetup 15Mydbops
 
Data-at-scale-with-TIDB Mydbops Co-Founder Kabilesh PR at LSPE Event
Data-at-scale-with-TIDB Mydbops Co-Founder Kabilesh PR at LSPE EventData-at-scale-with-TIDB Mydbops Co-Founder Kabilesh PR at LSPE Event
Data-at-scale-with-TIDB Mydbops Co-Founder Kabilesh PR at LSPE EventMydbops
 
MySQL Transformation Case Study: 80% Cost Savings & Uninterrupted Availabilit...
MySQL Transformation Case Study: 80% Cost Savings & Uninterrupted Availabilit...MySQL Transformation Case Study: 80% Cost Savings & Uninterrupted Availabilit...
MySQL Transformation Case Study: 80% Cost Savings & Uninterrupted Availabilit...Mydbops
 
Mastering MongoDB Atlas: Essentials of Diagnostics and Debugging in the Cloud...
Mastering MongoDB Atlas: Essentials of Diagnostics and Debugging in the Cloud...Mastering MongoDB Atlas: Essentials of Diagnostics and Debugging in the Cloud...
Mastering MongoDB Atlas: Essentials of Diagnostics and Debugging in the Cloud...Mydbops
 
Data Organisation: Table Partitioning in PostgreSQL
Data Organisation: Table Partitioning in PostgreSQLData Organisation: Table Partitioning in PostgreSQL
Data Organisation: Table Partitioning in PostgreSQLMydbops
 
Navigating MongoDB's Queryable Encryption for Ultimate Security - Mydbops
Navigating MongoDB's Queryable Encryption for Ultimate Security - MydbopsNavigating MongoDB's Queryable Encryption for Ultimate Security - Mydbops
Navigating MongoDB's Queryable Encryption for Ultimate Security - MydbopsMydbops
 
Data High Availability With TIDB
Data High Availability With TIDBData High Availability With TIDB
Data High Availability With TIDBMydbops
 
Mastering Database Migration_ Native replication (8.0) to InnoDB Cluster (8.0...
Mastering Database Migration_ Native replication (8.0) to InnoDB Cluster (8.0...Mastering Database Migration_ Native replication (8.0) to InnoDB Cluster (8.0...
Mastering Database Migration_ Native replication (8.0) to InnoDB Cluster (8.0...Mydbops
 
Enhancing Security of MySQL Connections using SSL certificates
Enhancing Security of MySQL Connections using SSL certificatesEnhancing Security of MySQL Connections using SSL certificates
Enhancing Security of MySQL Connections using SSL certificatesMydbops
 
Exploring the Fundamentals of YugabyteDB - Mydbops
Exploring the Fundamentals of YugabyteDB - Mydbops Exploring the Fundamentals of YugabyteDB - Mydbops
Exploring the Fundamentals of YugabyteDB - Mydbops Mydbops
 
Time series in MongoDB - Mydbops
Time series in MongoDB - Mydbops Time series in MongoDB - Mydbops
Time series in MongoDB - Mydbops Mydbops
 
TiDB in a Nutshell - Power of Open-Source Distributed SQL Database - Mydbops
TiDB in a Nutshell - Power of Open-Source Distributed SQL Database - MydbopsTiDB in a Nutshell - Power of Open-Source Distributed SQL Database - Mydbops
TiDB in a Nutshell - Power of Open-Source Distributed SQL Database - MydbopsMydbops
 
Achieving High Availability in PostgreSQL
Achieving High Availability in PostgreSQLAchieving High Availability in PostgreSQL
Achieving High Availability in PostgreSQLMydbops
 
MySQL Data Encryption at Rest
MySQL Data Encryption at RestMySQL Data Encryption at Rest
MySQL Data Encryption at RestMydbops
 
Top-10-Features-In-MySQL-8.0 - Vinoth Kanna RS - Mydbops Team
Top-10-Features-In-MySQL-8.0 - Vinoth Kanna RS - Mydbops TeamTop-10-Features-In-MySQL-8.0 - Vinoth Kanna RS - Mydbops Team
Top-10-Features-In-MySQL-8.0 - Vinoth Kanna RS - Mydbops TeamMydbops
 

More from Mydbops (20)

Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL Router
 
PostgreSQL Schema Changes with pg-osc - Mydbops @ PGConf India 2024
PostgreSQL Schema Changes with pg-osc - Mydbops @ PGConf India 2024PostgreSQL Schema Changes with pg-osc - Mydbops @ PGConf India 2024
PostgreSQL Schema Changes with pg-osc - Mydbops @ PGConf India 2024
 
Choosing the Right Database: Exploring MySQL Alternatives for Modern Applicat...
Choosing the Right Database: Exploring MySQL Alternatives for Modern Applicat...Choosing the Right Database: Exploring MySQL Alternatives for Modern Applicat...
Choosing the Right Database: Exploring MySQL Alternatives for Modern Applicat...
 
Mastering Aurora PostgreSQL Clusters for Disaster Recovery
Mastering Aurora PostgreSQL Clusters for Disaster RecoveryMastering Aurora PostgreSQL Clusters for Disaster Recovery
Mastering Aurora PostgreSQL Clusters for Disaster Recovery
 
Navigating Transactions: ACID Complexity in Modern Databases- Mydbops Open So...
Navigating Transactions: ACID Complexity in Modern Databases- Mydbops Open So...Navigating Transactions: ACID Complexity in Modern Databases- Mydbops Open So...
Navigating Transactions: ACID Complexity in Modern Databases- Mydbops Open So...
 
AWS RDS in MySQL 2023 Vinoth Kanna @ Mydbops OpenSource Database Meetup 15
AWS RDS in MySQL 2023 Vinoth Kanna @ Mydbops OpenSource Database Meetup 15AWS RDS in MySQL 2023 Vinoth Kanna @ Mydbops OpenSource Database Meetup 15
AWS RDS in MySQL 2023 Vinoth Kanna @ Mydbops OpenSource Database Meetup 15
 
Data-at-scale-with-TIDB Mydbops Co-Founder Kabilesh PR at LSPE Event
Data-at-scale-with-TIDB Mydbops Co-Founder Kabilesh PR at LSPE EventData-at-scale-with-TIDB Mydbops Co-Founder Kabilesh PR at LSPE Event
Data-at-scale-with-TIDB Mydbops Co-Founder Kabilesh PR at LSPE Event
 
MySQL Transformation Case Study: 80% Cost Savings & Uninterrupted Availabilit...
MySQL Transformation Case Study: 80% Cost Savings & Uninterrupted Availabilit...MySQL Transformation Case Study: 80% Cost Savings & Uninterrupted Availabilit...
MySQL Transformation Case Study: 80% Cost Savings & Uninterrupted Availabilit...
 
Mastering MongoDB Atlas: Essentials of Diagnostics and Debugging in the Cloud...
Mastering MongoDB Atlas: Essentials of Diagnostics and Debugging in the Cloud...Mastering MongoDB Atlas: Essentials of Diagnostics and Debugging in the Cloud...
Mastering MongoDB Atlas: Essentials of Diagnostics and Debugging in the Cloud...
 
Data Organisation: Table Partitioning in PostgreSQL
Data Organisation: Table Partitioning in PostgreSQLData Organisation: Table Partitioning in PostgreSQL
Data Organisation: Table Partitioning in PostgreSQL
 
Navigating MongoDB's Queryable Encryption for Ultimate Security - Mydbops
Navigating MongoDB's Queryable Encryption for Ultimate Security - MydbopsNavigating MongoDB's Queryable Encryption for Ultimate Security - Mydbops
Navigating MongoDB's Queryable Encryption for Ultimate Security - Mydbops
 
Data High Availability With TIDB
Data High Availability With TIDBData High Availability With TIDB
Data High Availability With TIDB
 
Mastering Database Migration_ Native replication (8.0) to InnoDB Cluster (8.0...
Mastering Database Migration_ Native replication (8.0) to InnoDB Cluster (8.0...Mastering Database Migration_ Native replication (8.0) to InnoDB Cluster (8.0...
Mastering Database Migration_ Native replication (8.0) to InnoDB Cluster (8.0...
 
Enhancing Security of MySQL Connections using SSL certificates
Enhancing Security of MySQL Connections using SSL certificatesEnhancing Security of MySQL Connections using SSL certificates
Enhancing Security of MySQL Connections using SSL certificates
 
Exploring the Fundamentals of YugabyteDB - Mydbops
Exploring the Fundamentals of YugabyteDB - Mydbops Exploring the Fundamentals of YugabyteDB - Mydbops
Exploring the Fundamentals of YugabyteDB - Mydbops
 
Time series in MongoDB - Mydbops
Time series in MongoDB - Mydbops Time series in MongoDB - Mydbops
Time series in MongoDB - Mydbops
 
TiDB in a Nutshell - Power of Open-Source Distributed SQL Database - Mydbops
TiDB in a Nutshell - Power of Open-Source Distributed SQL Database - MydbopsTiDB in a Nutshell - Power of Open-Source Distributed SQL Database - Mydbops
TiDB in a Nutshell - Power of Open-Source Distributed SQL Database - Mydbops
 
Achieving High Availability in PostgreSQL
Achieving High Availability in PostgreSQLAchieving High Availability in PostgreSQL
Achieving High Availability in PostgreSQL
 
MySQL Data Encryption at Rest
MySQL Data Encryption at RestMySQL Data Encryption at Rest
MySQL Data Encryption at Rest
 
Top-10-Features-In-MySQL-8.0 - Vinoth Kanna RS - Mydbops Team
Top-10-Features-In-MySQL-8.0 - Vinoth Kanna RS - Mydbops TeamTop-10-Features-In-MySQL-8.0 - Vinoth Kanna RS - Mydbops Team
Top-10-Features-In-MySQL-8.0 - Vinoth Kanna RS - Mydbops Team
 

Recently uploaded

Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile servicerehmti665
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxwendy cai
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxAsutosh Ranjan
 
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Serviceranjana rawat
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...Soham Mondal
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...srsj9000
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINESIVASHANKAR N
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidNikhilNagaraju
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxupamatechverse
 
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)Suman Mia
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Dr.Costas Sachpazis
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxpurnimasatapathy1234
 
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...ranjana rawat
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxupamatechverse
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingrakeshbaidya232001
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Dr.Costas Sachpazis
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024hassan khalil
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130Suhani Kapoor
 

Recently uploaded (20)

Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile service
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptx
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptx
 
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfid
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptx
 
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptx
 
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptx
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writing
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
 

Evolution of MonogDB Sharding and Its Best Practices - Ranjith A - Mydbops Team

  • 1. Evolution of MongoDB Sharding and Its Best Practices Presenter by Ranjith A Database Engineer @ Mydbops Mydbops 11th Webinar www.mydbops.com info@mydbops.com
  • 2. Ranjith A MongoDB Database Engineer ranjith@mydbops.com linkedin.com/in/ranjith-a-70aab0157 About Me
  • 3. Mydbops at a Glance ● Founded in 2015, HQ in Bangalore India, 70+ Employees. ● Mydbops is on Database Consulting with core specialization on MySQL, MongoDB and PostgreSQL Administration and Support. ● Mydbops was created with a motto of developing a DevOPS model for Database Administration. ● We help organisations to scale in MySQL/Mongodb/postgresql and implement the advanced technologies in MySQL/Mongodb/PostgreSQL.
  • 4. Mydbops at a Glance Happy Customers 4
  • 5. Agenda ● Intro ● Sharding Overview ● Sharding Architecture ● Types of Sharding ● Things need to be taken care before choosing shard key ● Evolution of sharding from 3.6 to 5.0 ● Q/A
  • 7. Sharding Overview ● Sharding is a method for distributing data across multiple machines. ● By using MongoDB sharding, We can handle very large data sets and high throughput operations. ● Database systems with large data sets or high throughput applications can challenge the capacity of a single server. ● For example, If our system is a heavy read sensitive it will exhaust the CPU capacity of the server. Working set sizes larger than the system's RAM stress the I/O capacity of disk drives.
  • 8. Sharding Overview We can scale the system in two engineering approach. Vertical Scaling Horizontal sharding Achieved by MongoDB replica set / standalone server Achieved by MongoDB Sharding Data set in Single server Distribute the data set to Multiple servers Increasing the server capacity of a single server. Adding additional servers to increase capacity as required. There is a limitation for increasing the server capacity We can easily add or remove additional servers as required.
  • 10. Sharding Architecture - (Data Shard) ● MongoDB supports horizontal scaling through MongoDB Sharded Cluster. ● MongoDB shards data at the collection level, distributing the collection data across the shards in the cluster. ● MongoDB Sharded Cluster consists of the following components: 1. Shards 2. Mongos 3. Config server Shard: ● Each shard contains a subset of the sharded data. ● Each shard can be deployed as a replica set.
  • 11. Sharding Architecture-(Mongos) Mongos: ● The mongos acts as a query router, providing an interface between client applications and the sharded cluster. ● Applications never connect or communicate directly with the shards. ● The mongos tracks what data is on which shard by caching the metadata from the config servers. ● The mongos uses the metadata to route operations from applications and clients to the mongod instances. ● The mongos receives responses from all shards, it merges the data and returns the result document.
  • 12. Sharding Architecture-(Config) Config Server: ● Config servers store metadata and configuration settings for the cluster. As of MongoDB 3.4, config servers must be deployed as a replica set (CSRS). ● If your cluster has a single config server, then the config server is a single point of failure. ● If the config server is inaccessible, the cluster is not accessible. ● If you cannot recover the data on a config server, the cluster will be inoperable. ● Always use three config servers for production deployments
  • 13. Types of Sharding-(Hashed Sharding) MongoDB supports two sharding methods for distributing data across sharded clusters. ● Hashed sharding ● Ranged Sharding Hashed sharding:
  • 14. Hashed sharding ● Hashed Sharding involves computing a hash of the shard key field's value. We can use either a single field hashed index or a compound hashed index (New in 4.4) as the shard key. ● MongoDB automatically computes the hashes when resolving queries using hashed indexes. ● Hashed sharding provides a more even data distribution across the sharded cluster. ● The fields which we chose the hashed shard key should have a good cardinality (more unique values). ● Default _id field is the best example for good cardinality (Objectid values).
  • 15. Hashed sharding Command to enable Sharding: (DB Level) sh.enableSharding("databasename")
  • 16. Hashed sharding Command to enable Sharding: (Collection Level) sh.shardCollection( "databasename.collectionname", { "field" : "hashed" } ) ● Make sure before enabling sharding for a particular collection database must be sharded also the Index must be available for the fields which we are going to use as a shard key.
  • 18. Ranged sharding ● In Range-based sharding, data's are splitted into contiguous ranges determined by the shard key values. ● Data with "close" shard key values are likely to be in the same chunk or shard. ● This will improve the performance of the read queries (target documents) within a contiguous range. ● Poor sharded key selection will affect both read and write performance. Command to enable Sharding: (Collection Level) sh.shardCollection( "databasename.collectionname", { "field" : 1 } ) ● Make sure before enabling sharding for a particular collection, database must be sharded also the Index must be available for the fields which we are going to use as a shard key.
  • 19. Zone sharding ● In sharded clusters, you can create single or multiple zones in single shard as well as multiple shards. ● Zones represent a group of shards and associate one or more ranges of shard key values to that zone. ● Zone ranges are always inclusive of the lower boundary and exclusive of the upper boundary. ● From MongoDB 4.0.2, dropping a collection deletes its associated zone/tag ranges. ● Zones information are stored in config.shards & config.tags collection ● Starting from MongoDB 4.4 brings we can shard a collection and determine zones by compound keys, including mixing a hashed key with non-hashed keys.
  • 20. Zone sharding Command to create Zone: sh.addShardToZone("shardname", "zonename")
  • 21. Zone sharding Command to create Zone range: sh.updateZoneKeyRange("dbname.collectionname", { fieldname: "minkey" }, { fieldname: "maxkey" }, "zonename")
  • 22. Sharded key Shard key is the key to evenly distribute the data among all shards. Good shared key always satisfies the below points. ● High Cardinality ● High Frequency ● Non Monotonically Changing Shard Keys ● Sharding Query patterns
  • 23. Sharded key High Cardinality: ● High cardinality shard key - More no. of chunks & evenly distributed data ● Low cardinality shard key - Less no. of chunks & low distributed data ● Each unique shard key value can exist on no more than a single chunk at any given time. High Frequency: ● High frequency shard key - More evenly distributed data ● Low frequency shard key - Low distributed data ● Shard key cardinality & monotonically changing shard key also contribute to the distribution of the data.
  • 24. Sharded key Non Monotonically Changing Shard Keys:- ● monotonically increases or decreases shard key tends to distribute the data to a single chunk within the cluster. ● Each chunk has its own min & Max value.
  • 25. Evolution of sharding from 3.6 to 5.0 Mongo version Modify shard key field value Refining shard key Change shard key New variables New features 3.6 NO NO NO orphanCleanupDelaySecs Shard must be a replica set All shard members have chunk metadata 4.2 YES NO NO sh.setBalancerState(true) sh.setBalancerState(false) Modify shard key field value except immutable _id field 4.4 YES YES NO Hedged Reads Refinable shard keys Hedged Reads compound shard keys with a hashed field Remove multiple shard at a time Remove shard key size limit 5.0 YES YES YES reshardCollection Change the shard key Change the name of a sharded collection
  • 26. Sharding Features in 3.6 ● Shards must be replica sets. ● All members of the shard replica set maintain the metadata regarding chunk metadata. This prevents reads from the secondaries from returning orphaned data. ● Based on the orphanCleanupDelaySecs (New in 3.6) variable migrated chunk is deleted from the source shard. ● orphanCleanupDelaySecs - Default 900 (15 min) Set the orphanCleanupDelaySecs value to 20 min during the mongo service start mongod --setParameter orphanCleanupDelaySecs=1200 (20 min) setParameter command: db.adminCommand( { setParameter: 1, orphanCleanupDelaySecs: 1200 } )
  • 27. Sharding Features in 4.2 ● We can update a document's shard key value except the shard key field is the immutable _id field. ● In earlier version we can't change the document's shard key value.
  • 28. Sharding Features in 4.2 New variables in 4.2: ● sh.startBalancer() - sh.setBalancerState(true) (Enable auto-splitting for the sharded cluster) ● sh.stopBalancer() - sh.setBalancerState(false) (Disable auto-splitting for the sharded cluster) ● sh.enableAutoSplit() - Enable auto-splitting when the balancer is disabled
  • 29. Sharding Features in 4.4 ● Refinable Shard Keys - refine a collection's shard key by adding a suffix field or fields to the existing key db.employee.createIndex({"employeeid" : 1, "mailid": 1}) db.adminCommand( {refineCollectionShardKey: "mydbops.employee", key: { "employeeid" : 1, "mailid": 1 }} ) ● In 4.4, Shard key field can be missing in a sharded collection. ● In earlier versions, shard key fields must exist in every document for a sharded collection. ● Support Hedged Reads - To minimize latencies ● Support compound shard keys with a hashed field. ● More than one removeShard operation at a time. ● MongoDB removes the 512-byte limit on the shard key size.
  • 30. Sharding Features in 5.0 ● We have a option to change the shard key by using reshardCollection command. ● To change the name of a sharded collection by using renameCollection command. Things need to be taken care before resharding: ● Initially MongoDB block writes to two seconds and begins the resharding operation. ● Available space should be 1.2x the size of the collection that you want to reshard. ● Ensure the Disk (50%) & CPU (80%) utilisation will be minimal. ● The new shard key cannot have a uniqueness constraint ● If a collection having uniqueness constraint is not supported for Resharding
  • 31. Sharding Features in 5.0 The following commands are not supported on the collection, while the resharding operation is in progress. ● collMod ● convertToCapped ● createIndexes ● createIndex() ● drop() ● dropIndexes ● dropIndex() ● renameCollection ● renameCollection()
  • 32. Sharding Features in 5.0 The following methods are not supported on the cluster, while the resharding operation is in progress. ● addShard ● removeShard ● db.createCollection() ● dropDatabase Resharded commands: ● db.adminCommand({ reshardCollection: "mydbops.client", key: {"cperiod": 1} } )