@@ -105,24 +105,23 @@ configuration, which provides a component of "data center awareness."
105105Background
106106~~~~~~~~~~
107107
108- By default, applications direct queries (i.e. read operations) to the
108+ By default, applications direct read operations to the
109109:term:`primary` member in a :term:`replica set`. When reading from the
110- the primary, all read operations are :term:`strictly consistent
111- <strict consistency>`. However, you can improve read performance and
110+ the primary, all read operations reflect the latest version of the document.
111+ However, you can improve read
112112throughput by distributing some or all reads to secondary members of
113- the replica set as needed. While secondary reads are :term:`eventually
114- consistent <eventual consistency>`, some applications may not require
115- strict consistency.
113+ the replica set as needed. While secondary reads may return stale data
114+ this is acceptable for applications that do not require fully up to date data.
116115
117- Reads from secondaries are eventually consistent because MongoDB can
118- not guarantee that secondary members will be consistent with the state
116+ Reads from secondaries may be stale MongoDB can
117+ not guarantee that secondary members will reflect the state
119118of the primary, which receives all incoming write operations. Do not
120- allow secondary reads, unless you can accept eventual consistency for
121- these operations .
119+ allow secondary reads, unless your application can handle receiving
120+ stale data .
122121
123- In many cases, your application will require the :term:`strict consistency`
124- that primary reads provide. However, typically secondary reads are
125- useful for:
122+ In many cases, your application will require the most current document
123+ that primary reads provide. However, the following use cases outline
124+ several potetial use cases for other read preferences :
126125
127126- running systems operations including backups and reports without
128127 impacting the front-end application.
@@ -132,18 +131,14 @@ useful for:
132131 than the primary or the rest of the set, you may see better
133132 performance for that application if you use secondary reads.
134133
135- Secondary reads also provide graceful degradation in
136- :ref:`failover <replica-set-failover>` situations. During failover, replica sets may take
137- 10 seconds or more to elect a new primary. Because there is no primary,
138- applications that can only read from primaries, with the
139- :readmode:`primary` read preference mode, are unable to perform reads during this period.
140- With read preference configured permit read from secondary
141- members, as with the :readmode:`primaryPrefered` read preference mode, your
142- application can continue read operations using the
143- remaining secondary members.
134+ - providing graceful degradation in :ref:`failover
135+ <replica-set-failover>` situations, when a set can have *no* primary
136+ for 10 seconds or more. If a set does not have a primary,
137+ applications with :readmode:`primary` cannot perform reads. Use the
138+ :readmode:`primaryPrefered` read preference in this situation.
144139
145140MongoDB :term:`drivers <driver>` allow client applications to
146- configure a :term:`read preference` on a per-connection or
141+ configure a :term:`read preference` on a per-connection, per-collection or
147142per-operation basis. See the :func:`rs.slaveOk()` method for more
148143information about secondary read operations in the :program:`mongo`
149144shell, as well as the appropriate :ref:`driver` API documentation for
@@ -154,19 +149,19 @@ address read preference configuration and operations.
154149
155150.. note::
156151
157- Read preference only affect which members of the set the application chooses
158- to read from. Read preferences only affect the members of the replica
159- set that the read operation uses, as well as the consistency of
160- query results . Use appropriate :ref:`write concern
152+ Read preferences affect how the application selects a member of the
153+ replica set to use for read operations. As a result read
154+ preferences dictate if the application will receive stale or
155+ current data from MongoDB . Use appropriate :ref:`write concern
161156 <replica-set-write-concern>` policies to ensure proper data
162157 replication and constancy.
163158
164159 If read operations account for a large percentage of your
165- application's traffic,distributing reads to secondary members may
166- provide some performance improvement . However, in most cases
167- :doc:`sharding </core/sharding>` will provide better support for
168- larger scale operations, because shard clusters can distribute read
169- and write operations across a group of machines.
160+ application's traffic, distributing reads to secondary members may
161+ improve read throughput . However, in most cases :doc:`sharding
162+ </core/sharding>` will provide better support for larger scale
163+ operations, because shard clusters can distribute read and write
164+ operations across a group of machines.
170165
171166.. index:: read preference; semantics
172167.. _replica-set-read-preference-semantics:
@@ -181,18 +176,18 @@ Read Preference Modes
181176All MongoDB drivers :doc:`drivers </applications/drivers>` support the
182177following read preference modes. These semantics make it possible to
183178specify read preference on a per-collection or per-operation
184- basis. The member of the :term:`replica set` that the client read from
185- can affect the consistency of the result set. See the :ref:`read
179+ basis. The member of the :term:`replica set` that the client reads from
180+ can affect how current or stale the result set is . See the :ref:`read
186181preference background <replica-set-read-preference-background>` and
187182:ref:`read preference behavior <replica-set-read-preference-behavior>`
188183for more information. Also see the :api:`documentation for your driver
189184<>` for specific read preference use. :program:`mongos` also supports
190185all read-preference modes in its connections to the replica sets that
191186provide each :term:`shard` in a :term:`shard cluster`.
192187
193- MongoDB drivers and :program:`mongos` all provide the five read
194- preference modes, which are constants set in the driver itself. The
195- exact name of the mode depends on driver implementation and the idioms
188+ All MongoDB drivers provide five read
189+ preference modes, which are constants set in the drivers
190+ themselves. While the names are the same, the exact syntax depends the idioms
196191of the host language. In the :program:`mongo` shell, the
197192:func:`readPreference() <cursor.readPreference()>` cursor method
198193provides access to read preferences, which have the following names.
@@ -211,6 +206,9 @@ provides access to read preferences, which have the following names.
211206 you specify a tag set with :readmode:`primary`, the driver will
212207 produce an error.
213208
209+ The :readmode:`primary` mode sacrifices availability for
210+ consistency, in terms of the :term:`CAP Theorm`.
211+
214212.. readmode:: primaryPrefered
215213
216214 With the :readmode:`primaryPrefered` read preference mode,
@@ -225,6 +223,9 @@ provides access to read preferences, which have the following names.
225223 tags. If there are no secondaries with tags that match the
226224 specified tags, this read operation will produce an error.
227225
226+ The :readmode:`primaryPrefered` mode sacrifices consistency for
227+ greater availability, in terms of the :term:`CAP Theorm`.
228+
228229.. readmode:: secondary
229230
230231 With the :readmode:`secondary` read preference mode, operations
@@ -244,6 +245,9 @@ provides access to read preferences, which have the following names.
244245 If there are no secondaries with tags that match the specified tag
245246 set, this read operation will produce an error.
246247
248+ The :readmode:`secondary` mode sacrifices consistency for
249+ greater availability, in terms of the :term:`CAP Theorm`.
250+
247251.. readmode:: secondaryPrefered
248252
249253 With the :readmode:`secondaryPrefered`, operations will read from
@@ -259,6 +263,9 @@ provides access to read preferences, which have the following names.
259263 If there are no secondaries with tags that match the specified tag
260264 set, this read operation will produce an error.
261265
266+ The :readmode:`secondaryPrefered` mode sacrifices consistency for
267+ greater availability, in terms of the :term:`CAP Theorm`.
268+
262269.. readmode:: nearest
263270
264271 With the :readmode:`nearest`, the driver will read from the
@@ -270,7 +277,7 @@ provides access to read preferences, which have the following names.
270277 secondaries.
271278
272279 Set this mode when you want minimize the effect of network latency
273- on read operations.
280+ on read operations without preference for current or stale data .
274281
275282 If you specify a :ref:`tag set <replica-set-read-preference-tag-sets>`,
276283 the client will attempt to find a secondary members that match the
@@ -319,7 +326,9 @@ each of the following read preference modes:
319326- :readmode:`secondaryPrefered`
320327- :readmode:`nearest`
321328
322- See the documentation of each read preference mode for more
329+ Tags only apply when :ref:`selecting <replica-set-read-preference-behavior-member-selection>`
330+ a :term:`secondary` member of the set, *except* for the
331+ :readmode:`nearest` mode. See the documentation of each read preference mode for more
323332information on the interaction of the read preference mode and tag
324333sets. All interfaces use the same :ref:`member selection logic
325334<replica-set-read-preference-behavior-member-selection>` to choose a
@@ -342,15 +351,15 @@ Auto-Retry
342351Connection between MongoDB drivers and :program:`mongod` instances in
343352a :term:`replica set` must balance two concerns:
344353
345- #. The client should attempt to maximize consistency and any
354+ #. The client should attempt to prefer current results and any
346355 connection should read from the same member of the replica set as
347356 much as possible.
348357
349358#. The client should minimize the amount of time that the database is
350359 inaccessible as the result of a connection issue, networking
351360 problem, or :term:`failover` in a replica set.
352361
353- As a result, MongoDB drivers, and :program:`mongos` will:
362+ As a result, MongoDB drivers and :program:`mongos` will:
354363
355364- reuse a connection to specific :program:`mongod` for as long as
356365 possible after establishing a connection to that instance. This
@@ -443,8 +452,10 @@ For any operation that will target a member *other* than the
443452#. determine which of these suitable members is the closest to the
444453 client in absolute terms.
445454
446- #. build a list of members that are, by default, within 15
447- milliseconds of the "absolute nearest" member. [#acceptable-secondary-latency]_
455+ .. defined fix
456+
457+ #. build a list of members that are within a defined ping distance (in
458+ milliseconds) of the "absolute nearest" member. [#acceptable-secondary-latency]_
448459
449460#. select a member to perform the read operation on from these hosts
450461 at random.
@@ -461,7 +472,6 @@ for more information.
461472 :option:`--localThreshold <mongos --localThreshold>` or
462473 :setting:`localThreshold` runtime options to set this value.
463474
464-
465475.. index:: read preference; sharding
466476.. index:: read preference; mongos
467477.. _replica-set-read-preference-behavior-sharding:
@@ -475,12 +485,15 @@ Sharding and ``mongos``
475485 :ref:`read preference mode semantics <replica-set-read-preference-modes>`.
476486
477487In most :term:`shard clusters <shard cluster>`, a :term:`replica set`
478- provides each shard, where read preferences are also
479- applicable. Unlike simple replica sets, in shard clusters, all
480- interactions with the shards pass from the clients to the
481- :program:`mongos` instances that are actually connected to the set
482- members. In these situations the :program:`mongos` is responsible for
483- the actual application of the read preferences.
488+ provides each shard, where read preferences are also applicable. Read
489+ operations in a shard cluster, with regard to read preference, are
490+ identical to unsharded replica sets.
491+
492+ Unlike simple replica sets, in shard clusters, all interactions with
493+ the shards pass from the clients to the :program:`mongos` instances
494+ that are actually connected to the set members. :program:`mongos` is
495+ responsible for the application of the read preferences, which is
496+ transparent to applications.
484497
485498There are no configuration changes required for full support of read
486499preference modes in sharded environments, as long as the
0 commit comments