liveBook · Manning

Replica set tag

As explained in MongoDB 8.0 in Action, Third Edition

A replica set tag is metadata assigned to a MongoDB replica set member that allows read preference selection to match members by attributes such as geographic location.

A replica set tag is member metadata that lets MongoDB match read preferences to attributes such as node type, region, provider, or availability zone. Atlas uses predefined tags to route applications toward suitable members and workload targets. section 10.5 section 10.7

Apply tags by combining them with a read preference:

  • Isolate ETL or reporting by using secondary reads with readPreferenceTags=nodeType:ANALYTICS. section 10.5.1
  • Keep ordinary secondary reads away from analytics workloads by targeting operational nodes with workloadType:OPERATIONAL. section 10.5.2
  • Prefer nearby members by listing geographic tag sets in priority order, then add an empty tag as a fallback. section 10.5.3
  • Use readPreference, readPreferenceTags, and readConcernLevel in a connection string; use cursor.readPref() or Mongo.setReadPref() in mongosh. section 10.5

Prefer local GCP regions

Use readPreference=nearest, then try provider:GCP with region:us-east1, provider:GCP with region:us-east4, and finally an empty tag to allow any available member. section 10.5.3

Table 10.5 Predefined replica set tags in Atlas

Tag name

Description

Example

Availability Zone

Identifies the AWS availability zone ID, GCP fully qualified name for a zone, or Azure zone number

AWS—{"availabilityZone": "use1-az3"},

GCP—{"availabilityZone": "us-east1-c"}

Azure—{"availabilityZone": "2"}

Node Type

Specifies the type of node. Possible values are ELECTABLE, READ_ONLY, and ANALYTICS.

{"nodeType": "ANALYTICS"}

Provider

Indicates the cloud provider where the node is provisioned. Possible values are AWS, GCP, and AZURE.

{"provider": "GCP"}

Region

Specifies the cloud region of the node

{"region": "US_EAST_2"}

Workload Type

Distributes your workload evenly among nonanalytics (electable or read-only) nodes. Possible value is OPERATIONAL.

{"workloadType": "OPERATIONAL"}

Disk State

Indicates the state of your disk. Possible value is READY.

{"diskState": "READY"}

Browse Atlas's predefined tag names and values for availability zones, node types, providers, regions, workload types, and disk state. section 10.5

How MongoDB 8.0 in Action, Third Edition covers it

How deep it goes
Explains predefined tags, connection options, ordered fallbacks, and mongosh alternatives without detailing tag creation or custom-member configuration.
Examples
Uses analytics-only reads, operational secondary reads, and nearest-region routing with a final unrestricted fallback.
What it assumes
Assumes familiarity with replica sets and read preferences while defining tag matching through concrete Atlas scenarios.
What you can do after
Configure read routing with connection-string options or apply read preferences through mongosh methods.
How it connects
Connects replica set tags with read preference, read concern, analytics nodes, operational reads, regions, and availability zones.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of MongoDB 8.0 in Action, Third Edition. The section links point to the parts of the book it draws on.