Navigation

Atlas Replica Set Tags

Feature unavailable in Free and Shared-Tier Clusters

This feature is not available for M0 (Free Tier), M2, and M5 clusters. To learn more about which features are unavailable, see Atlas M0 (Free Tier), M2, and M5 Limitations.

Atlas clusters are configured with pre-defined replica set tags for different member types in the cluster. You can utilize these pre-defined replica set tags to direct queries from specific applications to desired node types and regions. These tags sets allow you to customize read preferences for a replica set, thus improving cluster performance and reliability.

Replica Set Tag Descriptions

The following table describes the pre-defined replica set tags Atlas implements:

Tag Name Description Example
Provider

Cloud provider on which the node is provisioned.

Possible values are:

  • AWS
  • GCP
  • AZURE
{"provider" : "AWS"}
Region

Cloud region in which the node resides.

For a complete list of possible region values for each cloud provider, refer to the cloud provider’s reference page:

{"region" : "US_EAST_2"}
Node Type

Node type.

Possible values are:

  • ELECTABLE
  • READ_ONLY
  • ANALYTICS
{"nodeType" : "ANALYTICS"}

See also

For details on how these replica set tags correspond to BI Connector for Atlas read preferences, refer to the BI Connector cluster options section of the Create a Cluster Page.

Use Cases and Examples

The following section walks through distinct scenarios utilizing various pre-defined replica set tags, and sample connection strings for each.

Utilize Analytics Nodes to Isolate Workloads

If an application performs complex or long-running operations, such as ETL or reporting, you may want to isolate the application’s queries from the rest of your operational workload by connecting exclusively to analytics nodes.

In this case, the following connection string forces your application to only connect to analytic nodes:

mongodb+srv://<USERNAME>:<PASSWORD>@foo-q8x1v.mycluster.com/test?readPreference=secondary&readPreferenceTags=nodeType:ANALYTICS

The readPreference option of secondary and readPreferenceTag option of { nodeType:ANALYTICS } limit the application connections to analytic nodes.

Isolate Normal Application Secondary Reads from Analytics Nodes

In conjunction with the previous example, you may want to ensure that normal application reads from secondary nodes are isolated from the workload on analytics nodes.

In this case, the following connection string disallows the application from reading from analytics nodes and forces it to read from secondary nodes:

mongodb+srv://<USERNAME>:<PASSWORD>@foo-q8x1v.mycluster.com/test?readPreference=secondary&readPreferenceTags=nodeType:ELECTABLE&readPreferenceTags=nodeType:READ_ONLY

The readPreference option of secondary limits the application connections to secondary nodes. This option together with the read preference tags of { nodeType:ELECTABLE } and { nodeType:READ_ONLY } results in the application reading from electable secondary nodes, as indicated in the Read Preferences Table.

Target Local Reads for Geographically-Distributed Applications

You can utilize Atlas replica set tags to target local reads to specific regions for globally distributed applications. Prior to the introduction of these tags, local reads for globally distributed applications relied on correctly calculating the nearest read preference. With Atlas replica set tags, specifying appropriate geographic tags in combination with a read preference mode of nearest provides more consistent behavior.

The following connection string limits the application to connecting to AWS regions US_EAST_1 and US_EAST_2:

mongodb+srv://<USERNAME>:<PASSWORD>@foo-q8x1v.mycluster.com/test?readPreference=nearest&readPreferenceTags=provider:AWS,region:US_EAST_1&readPreferenceTags=provider:AWS,region:US_EAST_2

The read preference tags of { provider:AWS } and corresponding region tags dictate the specific regions within AWS to which the application can connect. These options help ensure that the application connects to the closest geographic region for reduced latency and improved performance.

See also

For additional information and use cases for various read preferences, refer to the Read Preference page in the MongoDB Manual.