Scaling and Security for MongoDBs
MongoDB scaling and security covers sharding, which splits a collection across shards by a shard key, and the controls that protect a deployment: authentication, role-based access control, TLS and network restrictions. It closes the Operations stage and deals with growth beyond one replica set and with limiting who can read the data.
Stage: Operations · Part of the MongoDB roadmap · Last reviewed 19 November 2026
What to learn in Scaling and Security
- Choose a shard key with high cardinality and even distribution
- Explain the roles of mongos, config servers and shards
- Enable authentication and create users with least-privilege roles
- Encrypt connections with TLS and restrict network access
- Recognise hot-shard and scatter-gather query problems
Scaling and Security interview questions
What makes a good shard key in MongoDB?
A good shard key has high cardinality, spreads writes evenly and appears in common queries so they target one shard. A monotonically increasing key such as a timestamp sends all new writes to one shard, creating a hot spot. Hashed keys can fix that.
When should you shard instead of adding replicas?
Replicas add availability and read capacity, but every member holds all the data. Shard when the data or write load exceeds what one machine can handle even after vertical scaling and indexing. Sharding adds complexity, so it should not be the first step.
Where Scaling and Security fits in the MongoDB roadmap
Scaling and Security belongs to the Operations stage (advanced level), which takes about 12 hours. Reliability and scale.
Other units in this stage
Back to the full MongoDB roadmap