|
| 1 | +.. _c2c-oplog-sizing: |
| 2 | + |
| 3 | +================ |
| 4 | +``oplog`` Sizing |
| 5 | +================ |
| 6 | + |
| 7 | +.. include:: /includes/preview-warning |
| 8 | + |
| 9 | +.. default-domain:: mongodb |
| 10 | + |
| 11 | +.. contents:: On this page |
| 12 | + :local: |
| 13 | + :backlinks: none |
| 14 | + :depth: 2 |
| 15 | + :class: singlecol |
| 16 | + |
| 17 | +The :ref:`mongosync <c2c-mongosync>` program uses :ref:`change streams |
| 18 | +<changeStreams>` to synchronize data between source and destination |
| 19 | +clusters. ``mongosync`` does not access the :term:`oplog` directly, |
| 20 | +but when a change stream returns events from the past, the events must |
| 21 | +be within the :term:`oplog` time range. |
| 22 | + |
| 23 | +.. include:: /includes/fact-oplog-background.txt |
| 24 | + |
| 25 | +Estimate ``oplog`` Size Needed for Initial Sync |
| 26 | +----------------------------------------------- |
| 27 | + |
| 28 | +.. procedure:: |
| 29 | + :style: normal |
| 30 | + |
| 31 | + .. step:: Determine the ``oplog`` Time Span |
| 32 | + |
| 33 | + To get the difference in seconds between the first and last entry |
| 34 | + in the ``oplog`` run :method:`db.getReplicationInfo()`. If you |
| 35 | + are replicating a sharded cluster, run the command on each shard. |
| 36 | + |
| 37 | + .. code-block:: javascript |
| 38 | + |
| 39 | + db.getReplicationInfo().timeDiff |
| 40 | + |
| 41 | + The value returned is the minimum ``oplog`` window of the |
| 42 | + cluster. If there are multiple shards, the smallest number is the |
| 43 | + minimum ``oplog`` window. |
| 44 | + |
| 45 | + .. step:: Estimate Copy Rate During Synching |
| 46 | + |
| 47 | + .. _c2c-step-est-size: |
| 48 | + |
| 49 | + To gather performance data while synching, start the sync process |
| 50 | + and monitor how fast data is transferred between clusters. |
| 51 | + |
| 52 | + To start syncing, run the :ref:`/start <c2c-api-start>` command. |
| 53 | + |
| 54 | + To get the ``copy_rate``: |
| 55 | + |
| 56 | + - run the :ref:`/progress <c2c-api-progress>` command to get |
| 57 | + ``estimatedCopiedBytes_time01`` |
| 58 | + - wait a second or two |
| 59 | + - run the :ref:`/progress <c2c-api-progress>` command to get |
| 60 | + ``estimatedCopiedBytes_time02`` |
| 61 | + |
| 62 | + The ``copy_rate`` is: |
| 63 | + |
| 64 | + .. code-block:: shell |
| 65 | + |
| 66 | + copy_rate = ( estimatedCopiedBytes_time02 - estimatedCopiedBytes_01) / time_between_requests |
| 67 | + |
| 68 | + .. step:: Estimate Copy Time |
| 69 | + |
| 70 | + Estimate the time needed to copy the entire collection. The |
| 71 | + estimated copy time is: |
| 72 | + |
| 73 | + .. code-block:: shell |
| 74 | + |
| 75 | + estimatedCopyTime = estimatedTotalBytes / copy_rate |
| 76 | + |
| 77 | + .. step:: Validate ``oplog`` Size |
| 78 | + |
| 79 | + If the estimated time is larger than the minimum oplog window you |
| 80 | + must cancel synchronization. Before restarting, make one of the |
| 81 | + following changes: |
| 82 | + |
| 83 | + - Increase the oplog window. Use :dbcommand:`replSetResizeOplog` |
| 84 | + to set ``minRetentionHours`` greater than the estimated copy |
| 85 | + time. |
| 86 | + - Scale up the ``mongosync`` instance. Add cpu or memory to scale |
| 87 | + up the ``mongosync`` node so that it has a higher copy rate. |
| 88 | + |
| 89 | +.. note:: |
| 90 | + |
| 91 | + The copy rate may vary during synchronization. To monitor progress, |
| 92 | + repeat the :ref:`steps to estimate the copy rate |
| 93 | + <c2c-step-est-size>` and verify that the copy rate stays about the |
| 94 | + same. |
| 95 | + |
0 commit comments