MONGO read preference reading priority setting

Source: Internet
Author: User
Read Preference mode for MONGO

MONGO query process, the default is the primary mode, that is, from the Master node query. There are other patterns, of course. A bit of the main mode is that you can always read the latest data, the disadvantage is that the read and write at the same node, the load is relatively high.

MONGO several modes of query,

Primary: By default, all are read from Primary's replica set

Primarypreferred: In most cases read from Primary's replica set, when it is not available, from its secondary members

Secondary: All read operations are read from secondary member

Secondarypreferred: Read from secondary member in most cases, when secondary member is not available, read from primary

Nearest: read from replica set with minimum network delay

It is important to note that the configuration is still in effect when read preference is connected through MONGOs.


process of Read preference

Member Selection (memberselection)

The driver and MONGOs of the client periodically update the state of the replica set

If you select Read preference for non-primary mode, then client driver determines which member to connect in the following way: The type of member (Primary,secondary,or all Members) collect a series of suitable member if the tag set is specified, then the member that do not match the tag set are excluded by absolute value which member is the closest distance to the client by the specified distance (ping time, The default is 15ms), you can find a series of members located within this distance, which can be defined as absolute nearest from the series of member selected randomly.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.