Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8687485
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T23:07:52+00:00 2026-06-12T23:07:52+00:00

I have 2 shards. One is over standalone server and another over replicaset: mongos>

  • 0

I have 2 shards.
One is over standalone server and another over replicaset:

mongos> db.runCommand({listshards:1})
{
        "shards" : [
            {
                "_id" : "shard0000",
                "host" : "mongo3:10001"
            },
            {
                "_id" : "set1",
                "host" : "set1/mongo1:10001,mongo2:10001"
            }
        ],
        "ok" : 1
}

I’ve inserted about 30M records.

As far as I understand mongo should balance equally the data between the shards, but it does not happen:

mongos> db.stats()
{
    "raw" : {
        "set1/mongo1:10001,mongo2:10001" : {
            "db" : "my_ginger",
            "collections" : 3,
            "objects" : 5308714,
            "avgObjSize" : 811.9953284354742,
            "dataSize" : 4310650968,
            "storageSize" : 4707774464,
            "numExtents" : 23,
            "indexes" : 2,
            "indexSize" : 421252048,
            "fileSize" : 10666115072,
            "nsSizeMB" : 16,
            "ok" : 1
        },
        "mongo3:10001" : {
            "db" : "my_ginger",
            "collections" : 6,
            "objects" : 25162626,
            "avgObjSize" : 1081.6777010475776,
            "dataSize" : 27217851444,
            "storageSize" : 28086624096,
            "numExtents" : 38,
            "indexes" : 6,
            "indexSize" : 1903266512,
            "fileSize" : 34276900864,
            "nsSizeMB" : 16,
            "ok" : 1
        }
    },
    "objects" : 30471340,
    "avgObjSize" : 1034.6936633571088,
    "dataSize" : 31528502412,
    "storageSize" : 32794398560,
    "numExtents" : 61,
    "indexes" : 8,
    "indexSize" : 2324518560,
    "fileSize" : 44943015936,
    "ok" : 1
}

What am I doing wrong?

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T23:07:53+00:00Added an answer on June 12, 2026 at 11:07 pm

    According the sh.status() output in the comments, you have 164 chunks on shard0000 (the single host) and 85 on set1 (the replica set). There are a couple of common reasons that this kind of imbalance can happen:

    1. You picked a bad shard key (monotonically increasing or similar)
    2. All your data was initially on a single shard and is being rebalanced

    The balancer will be continuously attempting to move chunks from the high shard to the low while at the same time moving the max-chunk around (for people that pick the aforementioned monotonically increasing keys, this helps). However, there can only be one migration at the time, so this will take some time, especially if you continue writing/reading from the shards at the same time. If things are really bad, and you did pick a poor shard key, then this may persist for some time.

    If all your data was on one shard first, and then you added another, then you have a similar problem – it will take a while for the chunk count to stabilise because half the data has to be moved from the original shard (in addition to its other activities) to balance things out. The balancer will pick low range chunks to move first in general, so if these are less likely to be in memory (back to the poor shard key again), then they will have to be paged in before they can be migrated.

    To check the balancer is running:

    http://docs.mongodb.org/manual/reference/method/sh.setBalancerState/#sh.getBalancerState

    Then, to see what it has been up to, connect to a mongos (last 10 operations):

    use config
    db.changelog.find().sort({$natural:-1}).limit(10).pretty()
    

    Similarly you will see messaging in the primary logs of each shard relating to the migrations, how long they are taking etc. if you want to see their performance.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In Mongo, it's possible to have a database residing in only one server (but
I've got mongodb running in following configuration: 1 config server, 2 mongos, 8 shards
I have an Ubuntu LAMJ server running Tomcat6. One of my JSP applications freezes
Have deployed numerous report parts which reference the same view however one of them
This is my situation:     I have a linux server/media center with a
Right now, I have configuration setting for morphia talks to one MongoDB from Play!.
We have a cost C which must be assigned to departments 1..n. Another computation
we have multisite UCM. As each VObs are stored in Server's directory, we use
I have a spreadsheet application in Java, and one of the features it provides
Problem: I have two spreadsheets that each serve different purposes but contain one particular

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.