Sharding Strategies

Learn how to design, implement, and manage sharded clusters to scale MongoDB horizontally and optimize performance.

Upon completion of the Sharding Strategies skill and skill check, you will earn a Credly Badge that you are able to share with your network.


  Learning Objectives

Set Up MongoDB Sharding Architecture

Explain MongoDB’s sharding architecture and the deployment process of a sharded cluster.

Distribute Data in a Sharded Cluster

Explain how to partition data across shards and manage unsharded collections within a sharded cluster.





Identify the Optimal Shard Key for Your Application

Implement the optimal shard key and data distribution option for your application's requirements.

Modify Your Sharding Strategy

Adapt your sharding strategy by resharding your collection with a new shard key, or by refining an existing shard key for evolving application demands.





Ryan Hamilton | Instructional Designer

Ryan Hamilton | Instructional Designer

Ryan Hamilton is an instructional designer on the University Enablement team at MongoDB. Prior to MongoDB, he worked at the Digital Learning Division at the Foreign Service Institute. He cares deeply about equipping learners with the tools they need to problem-solve, think creatively and critically, and innovate.

Katie Redmiles | Senior Curriculum Designer

Katie Redmiles | Senior Curriculum Designer

Katie is a Senior Curriculum Designer at MongoDB. Before joining the Curriculum team, Katie worked on the University Enablement team developing Learning Bytes and instructional materials for the MongoDB for Academia program. Katie also worked within the Digital Learning Division at the Foreign Service Institute where she honed her skills at developing online learning for a global audience. Katie is passionate about making education accessible and engaging for everyone.

Emilio Scalise | Senior Technologist

Emilio Scalise | Senior Technologist

Emilio is a multi-skilled IT specialist with a vast knowledge in system administration, databases, software development, network security, and cloud solutions. He is currently a Staff Technologist at MongoDB, producing internal and external learning materials. With over 8 years at MongoDB Support Organization, including five as a Staff Technical Support Engineer, he's developed considerable expertise in MongoDB's products and cloud services. In addition, Emilio is a certified MySQL DBA and experienced in technical translations between English and Italian.

Colleen Day | Curriculum Designer

Colleen Day | Curriculum Designer

Colleen is a Curriculum Designer at MongoDB. She holds a Masters degree in English literature from NYU, and is passionate about using writing as a vehicle to teach. She has worked as a writing instructor and ghostwriter, and has spent her career focused on educational content development. For several years, Colleen was the lead editor for The Princeton Review’s “Cracking the SAT” and other test prep books. Prior to MongoDB, she was Senior Managing Editor for boot camp courses on data science and fintech, partnering with subject matter experts to design and deliver courses for learners of all levels.

Manuel Fontan Garcia | Senior Technologist

Manuel Fontan Garcia | Senior Technologist

Manuel is a Senior Technologist on the Curriculum team at MongoDB. Previously he was a Senior Technical Services Engineer in the Core team at MongoDB. In between Manuel worked as a database reliability engineer at Slack for a little over 2 years and then for Cognite until he re-joined MongoDB. With over 15 years experience in software development and distributed systems, he is naturally curious and holds a Telecommunications Engineering MSc from Vigo University (Spain) and a Free and Open Source Software MSc from Rey Juan Carlos University (Spain).

Davenson Lombard | Senior Software Engineer

Davenson Lombard | Senior Software Engineer

Davenson Lombard is a Senior Software engineer at MongoDB on the Education Team. Prior to that, Davenson was a Technical Services Engineer at MongoDB and a Customer Success architect at Confluent. Davenson holds a Bachelor in Electrical Engineering from Concordia University in Montreal.

John McCambridge | University Curriculum Engineer

John McCambridge | University Curriculum Engineer

John is a Curriculum Engineer on the University team at MongoDB. Before his work as a Curriculum Engineer, he was an instructor and teaching assistant for coding boot camps at UT (Austin), and UCLA. Additionally, he worked as a QA engineer for a startup called Coder and spent five years at Apple Inc. John is a passionate software engineer and educator who enjoys taking complex topics and making them digestible for the community.

Welcome. We're excited to help you learn how to implement sharding, MongoDB's horizontal scaling solution for modern applications.

My name is Katie.

I'm a senior curriculum designer at MongoDB, and I'll be guiding you through this skill badge.

Have you ever wondered how massive applications, like banking systems, social media platforms, or ecommerce giants handle millions of users and endless streams of data without crashing? It's because of scaling strategies such as sharding.

Sharding, a type of horizontal scaling, breaks up data and spreads it across multiple servers.

Instead of cramming everything into one overloaded server, MongoDB breaks the data into smaller, manageable chunks, distributing the data across multiple machines.

This improves the efficiency of queries by distributing them across the cluster, allowing your database to support growth as your application scales. This technique is crucial for applications with large amounts of data, data that is geographically distributed, and data that handles operation intensive workloads.

In this skill badge, we'll begin by giving you an overview of sharding architecture in MongoDB.

You'll learn how key components like shards, the mongos router, and the config server work together to provide scalability and high availability.

We'll also walk through how to set up and deploy a sharded cluster and how to distribute data across shards.

From there, we'll explore the core concepts to ensure success when sharding in MongoDB, choosing an optimal shard key and implementing a distribution option.

The shard key determines how your data is distributed when partitioning across multiple shards.

Choosing an inefficient shard key can lead to imbalanced shards and performance bottlenecks.

To help you choose the optimal shard key, we'll show you how to use the analyze shard key command. The selection of the shard key is also fundamental to implementing a distribution option.

In this skill badge, we'll cover three options starting with range sharding, the default option for most sharding use cases.

We will also cover hashed and zone to sharding, which are versions of range sharding used for special use cases.

Finally, we'll cover what to do if you need to change your shard key. Maybe it's not efficient enough and therefore causes performance bottlenecks or maybe your workload changes.

In these cases, you need to modify your sharding strategy.

We'll first talk about resharding, which changes the collection's shard key and redistributes all the data based on the new key. We will also cover refining the shard key, which adds additional fields to an existing shard key. Throughout this skill badge, we will apply all the steps to shard successfully with MongoDB to the fictional banking for Leafy Bank. As a growing banking institution, Leafy Bank now has over ten million users.

Leafy Bank's rapid growth has put a strain on their database.

They need to shard to improve performance.

Throughout the badge, we will follow Leafy Bank's journey to scale. You will also have the opportunity to practice what you have learned by completing a hands on lab that presents real world scenarios.

When you're finished, you'll be ready to put your new skills to the test.

To earn your badge, simply complete all the related content and then take the short skill check at the end. After passing it, you'll receive an official Credly badge via the email you provided.

Be sure to share your badge on LinkedIn to show off your new skills.

Sharding is a game changer for large scale applications, allowing databases to handle massive workloads efficiently while maintaining speed and reliability.

By completing this badge, you will be able to design a strategic sharding architecture for your workload and implement the right shard key.