@@ -263,12 +263,12 @@ Shard Key Indexes
263
263
264
264
All sharded collections **must** have an index that starts with the
265
265
:term:`shard key`. If you shard a collection that does not yet contain
266
- documents and *without* such an index, the :dbcommand:`shardCollection`
266
+ documents and *without* such an index, the :dbcommand:`shardCollection`
267
267
will create an index on the shard key. If the collection already
268
268
contains documents, you must create an appropriate index before using
269
269
:dbcommand:`shardCollection`.
270
270
271
- .. TODO replace the link
271
+ .. TODO replace the link
272
272
273
273
.. versionchanged:: 2.2
274
274
The index on the shard key no longer needs to be identical to the
@@ -304,7 +304,7 @@ and you want to replace this with an index on the field ``{ zipcode:
304
304
305
305
If you drop the last appropriate index for the shard key, recover
306
306
by recreating a index on just the shard key.
307
-
307
+
308
308
.. index:: balancing; internals
309
309
.. _sharding-balancing-internals:
310
310
@@ -333,8 +333,8 @@ chunks in a collection is unevenly distributed among the shards, the
333
333
balancer begins migrating :term:`chunks <chunk>` from shards with more
334
334
chunks to shards with a fewer number of chunks. The balancer will
335
335
continue migrating chunks, one at a time, until the data is evenly
336
- distributed among the shards (i.e. the difference between any two
337
- shards is less than 2 chunks.)
336
+ distributed among the shards. See the :ref:`migration thresholds
337
+ <sharding-migration-thresholds>` section for more information.
338
338
339
339
While these automatic chunk migrations are crucial for distributing
340
340
data, they carry some overhead in terms of bandwidth and workload,
@@ -353,6 +353,36 @@ sends all new writes, to the "receiving" server. Finally,
353
353
:program:`mongos` updates the chunk record in the :term:`config
354
354
database` to reflect the new location of the chunk.
355
355
356
+ .. _sharding-migration-thresholds:
357
+
358
+ Migration Thresholds
359
+ ~~~~~~~~~~~~~~~~~~~~
360
+
361
+ .. versionchanged:: 2.2
362
+ The following thresholds appear first in 2.2; prior to this
363
+ release, balancing would only commence if the shard with the most
364
+ chunks had 8 more chunks than the shard with the least number of
365
+ chunks.
366
+
367
+ In order to minimize the impact of balancing on the cluster, the
368
+ :term:`balancer` will not begin balancing until the distribution of
369
+ chunks has reached certain thresholds. These thresholds apply to the
370
+ difference in number of :term:`chunks <chunk>` between the shard with
371
+ the greatest number of chunks and the shard with the least number of
372
+ chunks. The balancer has the following thresholds:
373
+
374
+ ================ ===================
375
+ Number of Chunks Migration Threshold
376
+ ---------------- -------------------
377
+ Greater than 80 8
378
+ 80-21 4
379
+ Less than 20 2
380
+ ================ ===================
381
+
382
+ Once a balancing round starts, the balancer will not stop until the
383
+ difference between the number of chunks on any two shards is *less
384
+ than two.*
385
+
356
386
.. index:: sharding; chunk size
357
387
.. _sharding-chunk-size:
358
388
0 commit comments