@@ -200,27 +200,37 @@ MongoDB, see :doc:`/core/read-isolation-consistency-recency`.
200200Mirrored Reads
201201~~~~~~~~~~~~~~
202202
203- Starting in version 4.4, MongoDB provides mirrored reads to pre-warm
204- the cache of electable secondary members (i.e. members with
205- :rsconf:`priority greater than 0 <members[n].priority>`). With mirrored
206- reads (which is enabled by default), the primary can mirror a subset of
207- :ref:`operations <mirrored-reads-supported-operations>` that it
208- receives and send them to a subset of electable secondaries. The size
209- of the subset is :ref:`configurable <mirrored-reads-parameters>`.
203+ Mirrored reads reduce the impact of primary elections following an
204+ outage or planned maintenance. After a :term:`failover` in a replica
205+ set, the secondary that takes over as the new primary updates its cache
206+ as new queries come in. While the cache is warming up performance can be
207+ impacted.
208+
209+ Starting in version 4.4, mirrored reads pre-warm the caches of
210+ :rsconf:`electable <members[n].priority>` secondary replica set members.
211+ To pre-warm the caches of electable secondaries, the primary mirrors a
212+ sample of the :ref:`supported operations
213+ <mirrored-reads-supported-operations>` it receives to electable
214+ secondaries.
215+
216+ The size of the subset of :rsconf:`electable <members[n].priority>`
217+ secondary replica set members that receive mirrored reads can be
218+ configured with the :parameter:`mirrorReads <mirrorReads>`
219+ parameter. See :ref:`Enable/Disable Support for Mirrored Reads
220+ <mirrored-reads-parameters>` for further details.
210221
211222.. note::
212223
213- The primary's response to the client is not affected by the mirror
214- reads. The mirrored reads are "fire-and-forget" operations by the
215- primary; i.e., the primary does not await the response for the
216- mirrored reads.
224+ Mirrored reads do not affect the primary's response to the client.
225+ The reads that the primary mirrors to secondaries are
226+ "fire-and-forget" operations. The primary doesn't await responses.
217227
218228.. _mirrored-reads-supported-operations:
219229
220230Supported Operations
221231````````````````````
222232
223- Mirrored reads are supported for the following operations:
233+ Mirrored reads support the following operations:
224234
225235- :dbcommand:`count`
226236
@@ -239,36 +249,56 @@ Mirrored reads are supported for the following operations:
239249Enable/Disable Support for Mirrored Reads
240250`````````````````````````````````````````
241251
242- With MongoDB 4.4, mirrored reads are enabled by default and use a
243- default :parameter:`sampling rate <mirrorReads>` of ``0.01``.
244- That is, the primary mirrors :ref:`reads
245- <mirrored-reads-supported-operations>` to each electable (i.e.
246- :rsconf:`priority greater than 0 <members[n].priority>`) secondary at
247- the sampling rate of 1 percent.
252+ Starting in MongoDB 4.4, mirrored reads are enabled by default and use a
253+ default :parameter:`sampling rate <mirrorReads>` of ``0.01``. To disable
254+ mirrored reads, set the :parameter:`mirrorReads` parameter to ``{
255+ samplingRate: 0.0 }``:
248256
249- For example, given a replica set with a primary and two electable
250- secondaries and a sampling rate of ``0.01``, if the primary receives
251- ``100`` operations that can be mirrored, the sampling may result in
252- ``1`` reads being mirrored to one secondary and ``0`` reads to the
253- other or ``0`` to each, etc.
254-
255- To modify the sampling rate, use the :parameter:`mirrorReads` parameter:
256-
257- - A sampling rate value of ``0.0`` disables mirrored reads.
258-
259- - A sampling rate greater than ``0.0`` enables mirrored reads.
257+ .. code-block:: javascript
260258
261- - A sampling rate cannot be greater than ``1.0``.
259+ db.adminCommand( {
260+ setParameter: 1,
261+ mirrorReads: { samplingRate: 0.0 }
262+ } )
263+
264+ With a sampling rate greater than ``0.0``, the primary mirrors
265+ :ref:`supported reads <mirrored-reads-supported-operations>` to a subset
266+ of :rsconf:`electable <members[n].priority>` secondaries. With a
267+ sampling rate of ``0.01``, the primary mirrors one percent of the
268+ supported reads it receives to each electable secondary.
269+
270+ Consider a replica set that consists of one primary and two electable
271+ secondaries. If the primary receives ``1000`` operations that can be
272+ mirrored and the sampling rate is ``0.01``, the primary sends
273+ about ``10`` reads to electable secondaries. Each electable secondary
274+ receives only a fraction of the 10 reads. Each read that is mirrored, is
275+ sent to a randomly chosen non-empty selection of electable secondaries.
276+
277+ Change the Sampling Rate for Mirrored Reads
278+ ```````````````````````````````````````````
279+
280+ To change the sampling rate for mirrored reads, set the
281+ :parameter:`mirrorReads` parameter to a number between ``0.0`` and
282+ ``1.0``:
283+
284+ - A sampling rate of ``0.0`` disables mirrored reads.
285+ - A sampling rate of a number between ``0.0`` and ``1.0`` results in
286+ the primary forwarding a random sample of the :ref:`supported reads
287+ <mirrored-reads-supported-operations>` at the specified sample rate to
288+ electable secondaries.
289+ - A sampling rate of ``1.0`` results in the primary forwarding all
290+ :ref:`supported reads <mirrored-reads-supported-operations>` to
291+ electable secondaries.
262292
263293For details, see :parameter:`mirrorReads`.
264294
265295Mirrored Reads Metrics
266296``````````````````````
267297
268- Starting in MongoDB 4.4, the command :dbcommand:`serverStatus` and its
269- corresponding :binary:`~bin.mongo ` shell method
270- :method:`db.serverStatus()` return : serverstatus:`mirroredReads` if you
271- specify the field's inclusion in the operation. For example,
298+ Starting in MongoDB 4.4, the :dbcommand:`serverStatus` command and the
299+ :method:`db.serverStatus() ` shell method return
300+ :serverstatus:`mirroredReads` metrics if you specify the field in the
301+ operation:
272302
273303.. code-block:: javascript
274304
0 commit comments