Skip to content
Learn Netverks

Lesson

Step 32/36 89% through track

sharding-preview-mongodb

Sharding preview

Last reviewed Jun 1, 2026 Content v20260601
Track mode
none
Means
Read / quiz
Reading
~1 min
Level
advanced

This lesson

This lesson teaches Sharding preview: document modeling, query operators, and aggregation patterns for MongoDB.

HA and scale change ops—elections, lag, and shard keys show up in senior backend interviews.

You will apply Sharding preview in contexts like: Content catalogs, event logs, mobile sync backends, and polyglot stacks beside SQL services.

Copy JavaScript shell queries from each lesson into mongosh or MongoDB Atlas Data Explorer—inspect matched documents and explain plans. The in-browser lab (execution_profile: none) ships later; mongosh is the practice path now.

When find, operators, and basic aggregation pipelines feel familiar in mongosh.

Sharding splits data across shards by shard key—horizontal scale when one replica set is not enough.

Components

  • mongos — query router
  • config servers — cluster metadata
  • shards — replica sets holding data chunks

Shard key choice

High cardinality, even distribution—avoid monotonic _id-only hot shard unless hashed.

// Hashed shard key example concept:
sh.shardCollection('practice.events', { userId: 'hashed' })

Practice: Concepts apply to Atlas and self-hosted; try read-only commands in mongosh where safe.

Important interview questions and answers

  1. Q: Shard key immutable?
    A: Generally fixed at shardCollection time—bad keys are expensive to fix.
  2. Q: Targeted vs scatter-gather?
    A: Queries including shard key hit one shard; others fan out.

Self-check

  1. What does mongos do?
  2. Monotonic _id shard risk?

Tip: Choose shard key before data size makes resharding painful.

Interview prep

mongos?
Routes queries to correct shards.
Shard key?
Determines data distribution across shards.

Interview tip Lesson completion confidence

Can you explain this lesson in 30 seconds without reading notes?

Not saved yet.

Check yourself

Multiple choice — immediate feedback.

Discussion

Past discussion is visible to everyone. Only logged-in users can post comments and replies.

Starter discussion topics

  • Shard key pick?
  • mongos role?

Sign up or log in to post comments and sync lesson progress across devices.

No discussion yet. Be the first to ask a question.

Jump