Re: [mongodb-user] Balancer not rebalancing shards after changing maxSize

399 views
Skip to first unread message

Exi

unread,
Aug 10, 2012, 10:52:32 AM8/10/12
to mongod...@googlegroups.com
Sorry for the double post, but the mailing list took over an hour to
send me this mail, so i figured that maybe it got lost somehow.
Just ignore this post and see the other post of me which has more infos
anyways.

Sorry,
Exi

markh

unread,
Aug 10, 2012, 12:07:15 PM8/10/12
to mongod...@googlegroups.com
Hi Exi,

There's a slight misunderstanding of what "maxSize" does.

When "maxSize" is configured, it will stop chunks being migrated to the shard from other shards once that size limit has been reached. Setting maxSize itself (as you've done) will not force chunks to move off the shard and things are working as designed.

Typically, a maximum size is configured for any shard when you first shard or add a shard using the "maxSize" parameter of the "addshard" command, not after. For example -

> db.runCommand( { addshard : "shard3", maxSize:100000/*MB*/ } );

The "maxSize" setting lets you tell the system a maximum amount of disk space in megabytes to use on the specified shard. If unspecified, the system will use the entire disk. The balancer will not migrate chunks to the shard when the value of "mem.mapped"exceeds the "maxSize" setting. 

If you are concerned that your shard is near capacity, then you are correct that you need to manage the situation before it gets to close to capacity. You can manually move the chunks as outlined here and the shard cluster administration (from a chunk management perspective) is outlined here.

Thanks
Mark

Exi

unread,
Aug 10, 2012, 12:16:20 PM8/10/12
to mongod...@googlegroups.com
On 10.08.2012 18:07, markh wrote:
If you are concerned that your shard is near capacity, then you are correct that you need to manage the situation before it gets to close to capacity. You can manually move the chunks as outlined here and the shard cluster administration (from a chunk management perspective) is outlined here.


Thanks for the clarification,
I have begun to manually move chunks away from the shard to keep up with the writes.
Am I interpreting this correctly? maxSize will not prevent a size increase on the shard through writes and in no situation will the balancer move chunks away from the shard if it is over capacity?
This would really be a disappointment because it means that no matter how I manage my data, I'll have to write my own balancing scripts to move away any excess data that is written to that particular shard over time, even though there is plenty of space on other shards.
Or am I missing something important here to manage the disk usage of my shards?

Regards,
Exi

markh

unread,
Aug 14, 2012, 11:15:41 AM8/14/12
to mongod...@googlegroups.com
Hi Exi,

The maxSize parameter lets you tell the system a maximum amount of disk space in megabytes to use on the specified shard. Unless specified, shards will consume the total amount of available space on their machines if necessary, however, maxSize does not move chunks (remember chunks are logical).

Typically, maxSize is configured at the beginning (in your case you didn't apply it until later).

As per this ticket, maxSize is more of a soft-limit. As per Eliot's recommendation, it's advisable to set the maxSize to 70% or so of the disk size.

In 2.0, balancing would only commence if the shard with the most chunks had 8 more chunks than the shard with the least number of chunks.

In version 2.2, the balancer has the following thresholds -

Number of Chunks        Migration Threshold
Greater than 80                          8
80-21                                           4
Less than 20                               2

In order to minimize the impact of balancing on the cluster, the balancer will not begin balancing until the distribution of chunks has reached certain thresholds. These thresholds apply to the difference in number of chunks between the shard with the greatest number of chunks and the shard with the least number of chunks.  Once a balancing round starts, the balancer will not stop until the difference between the number of chunks on any two shards is less than two.

Mark

Exi

unread,
Aug 14, 2012, 12:29:39 PM8/14/12
to mongod...@googlegroups.com
On 08/14/2012 05:15 PM, markh wrote:> In order to minimize the impact of balancing on the cluster,
the balancer will not begin balancing
> until the distribution of chunks has reached certain thresholds. These thresholds apply to the
> difference in number of chunks between the shard with the greatest number of chunks and the shard
> with the least number of chunks. Once a balancing round starts, the balancer will not stop until
> the difference between the number of chunks on any two shards is less than two.
>
> Mark

Hi,
thanks for the clarifications.
I already "solved" my problem of uneven disk sizes between servers.
I use sharding mainly to distribute the data (as in Gibibytes) across servers, not the load. So
handling uneven disk sizes is more of an issue than uneven load distribution.
I just disabled the build in balancer and implemented my own (crude) balancer which support chunk
splitting and chunk movement according to the disk space characteristics of my servers.
This way I am able to better utilize my disk space without regarding load distribution in any way
(which is fairly unimportant in my case).

Exi
Reply all
Reply to author
Forward
0 new messages