Bird
Raised Fist0
MongoDBquery~20 mins

Horizontal scaling mental model in MongoDB - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
Horizontal Scaling Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Understanding horizontal scaling basics

Which statement best describes horizontal scaling in a database system like MongoDB?

AAdding more servers to distribute the load and data across multiple machines.
BIncreasing the CPU and RAM of a single server to handle more requests.
CUsing caching to reduce database read operations on a single server.
DCompressing data to reduce storage space on one server.
Attempts:
2 left
💡 Hint

Think about spreading data and load across many machines instead of upgrading one.

❓ Architecture
intermediate
2:00remaining
MongoDB sharding architecture

In MongoDB horizontal scaling, what is the role of the config servers in a sharded cluster?

AThey store metadata and configuration about the cluster’s data distribution.
BThey hold the actual user data and respond to queries directly.
CThey act as backup servers for data replication.
DThey cache frequently accessed data to speed up reads.
Attempts:
2 left
💡 Hint

Think about which servers keep track of where data lives in the cluster.

❓ scaling
advanced
2:00remaining
Scaling write operations in MongoDB

Which horizontal scaling strategy best improves write throughput in a MongoDB cluster?

AEnabling read preference to secondary nodes to balance writes.
BSharding data across multiple shards based on a shard key to distribute writes.
CUsing a single powerful server with SSD storage for faster writes.
DAdding more replicas to the replica set to increase write capacity.
Attempts:
2 left
💡 Hint

Consider how writes can be spread across multiple machines.

❓ tradeoff
advanced
2:00remaining
Tradeoffs in choosing a shard key

What is a key tradeoff when selecting a shard key for horizontal scaling in MongoDB?

AChoosing a shard key increases the size of each document stored.
BShard keys limit the number of indexes you can create on a collection.
CA poor shard key can cause uneven data distribution leading to hotspots.
DShard keys prevent the use of replica sets for data redundancy.
Attempts:
2 left
💡 Hint

Think about how data is spread across servers and what happens if it’s uneven.

❓ estimation
expert
2:00remaining
Estimating capacity for a sharded MongoDB cluster

You expect 1 million writes per minute and want to keep write latency low by horizontal scaling. If one shard can handle 100,000 writes per minute, how many shards do you need at minimum?

A1 shard
B5 shards
C20 shards
D10 shards
Attempts:
2 left
💡 Hint

Divide total writes by writes per shard to find minimum shards needed.

Practice

(1/5)
1. What does horizontal scaling in MongoDB primarily involve?
easy
A. Adding more servers to share the data load
B. Increasing the CPU power of a single server
C. Using faster disks on the existing server
D. Compressing data to save space

Solution

  1. Step 1: Understand horizontal scaling concept

    Horizontal scaling means adding more machines to handle more data or users.
  2. Step 2: Apply to MongoDB context

    MongoDB uses sharding to distribute data across multiple servers, which is horizontal scaling.
  3. Final Answer:

    Adding more servers to share the data load -> Option A
  4. Quick Check:

    Horizontal scaling = adding servers [OK]
Hint: Horizontal scaling means more servers, not bigger servers [OK]
Common Mistakes:
  • Confusing horizontal scaling with vertical scaling
  • Thinking faster disks alone is horizontal scaling
  • Mixing data compression with scaling
2. Which MongoDB feature is used to implement horizontal scaling?
easy
A. Sharding
B. Indexing
C. Replication
D. Aggregation

Solution

  1. Step 1: Recall MongoDB scaling features

    Replication copies data for backup and availability, not scaling data horizontally.
  2. Step 2: Identify horizontal scaling feature

    Sharding splits data across servers to scale horizontally.
  3. Final Answer:

    Sharding -> Option A
  4. Quick Check:

    Horizontal scaling = Sharding [OK]
Hint: Sharding splits data across servers horizontally [OK]
Common Mistakes:
  • Confusing replication with sharding
  • Thinking indexing scales data horizontally
  • Mixing aggregation with scaling
3. Given a MongoDB cluster with 3 shards, each holding 1 million documents, what happens when you add a 4th shard?
medium
A. The cluster stops working until manually rebalanced
B. New data only goes to the 4th shard, old data stays on first 3
C. All data duplicates on the 4th shard
D. Data automatically redistributes to balance across all 4 shards

Solution

  1. Step 1: Understand shard addition effect

    Adding a shard triggers MongoDB to redistribute chunks to balance data load.
  2. Step 2: Analyze options

    Data automatically redistributes to balance across all 4 shards matches MongoDB's automatic balancing; others describe incorrect behaviors.
  3. Final Answer:

    Data automatically redistributes to balance across all 4 shards -> Option D
  4. Quick Check:

    Shard addition triggers auto-balancing [OK]
Hint: Adding shards triggers automatic data balancing [OK]
Common Mistakes:
  • Assuming new shard only gets new data
  • Thinking data duplicates on new shard
  • Believing manual rebalance is always required
4. You configured a MongoDB sharded cluster but notice all queries hit only one shard. What is the likely cause?
medium
A. Replication is not enabled
B. Shard key is not properly chosen or missing
C. Indexes are missing on all shards
D. The cluster has too many shards

Solution

  1. Step 1: Understand shard key role

    The shard key determines how data is distributed and which shard handles queries.
  2. Step 2: Diagnose query routing issue

    If all queries hit one shard, shard key is likely missing or poorly chosen, causing no data distribution.
  3. Final Answer:

    Shard key is not properly chosen or missing -> Option B
  4. Quick Check:

    Shard key controls query distribution [OK]
Hint: Proper shard key ensures queries spread across shards [OK]
Common Mistakes:
  • Blaming replication for query routing
  • Assuming indexes affect shard routing
  • Thinking too many shards cause single shard hits
5. You have a MongoDB cluster with 5 shards. Your application experiences uneven load because one shard stores much more data than others. What is the best solution to fix this?
hard
A. Increase RAM on the overloaded shard server
B. Add more replicas to the overloaded shard
C. Choose a better shard key that evenly distributes data
D. Disable sharding and use a single server

Solution

  1. Step 1: Identify cause of uneven load

    Uneven data distribution usually means the shard key does not distribute data evenly.
  2. Step 2: Select best fix

    Changing to a better shard key balances data and load across shards, improving performance.
  3. Final Answer:

    Choose a better shard key that evenly distributes data -> Option C
  4. Quick Check:

    Balanced shard key = even load [OK]
Hint: Good shard key balances data evenly across shards [OK]
Common Mistakes:
  • Adding replicas does not fix data imbalance
  • Increasing RAM only helps performance, not distribution
  • Disabling sharding removes scaling benefits
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard