Skip to content
Studio 3T - The professional GUI, IDE and client for MongoDB
  • Tools
    • Aggregation Editor
    • IntelliShell
    • Visual Query Builder
    • Export Wizard
    • Import Wizard
    • Query Code
    • SQL Query
    • Connect
    • Schema Explorer
    • Compare
    • SQL ⇔ MongoDB Migration
    • Data Masking
    • Task Scheduler
    • Reschema
    • More Tools and Features
  • Solutions
  • Resources
    • Knowledge Base
    • MongoDB Tutorials & Courses
    • Tool/Feature Documentation
    • Blog
    • Community
    • Testimonials
    • Whitepapers
    • Reports
  • Contact us
    • Contact
    • Sales Support
    • Feedback and Support
    • Careers
    • About Us
  • Store
    • Buy Now
    • Preferred Resellers
    • Team Pricing
  • Download
  • My 3T
search

MongoDB Atlas, Read Preference Tags and Studio 3T

Posted on: 26/08/2021 (last updated: 01/09/2021) by Dj Walker-Morgan

In the latest version of Studio 3T, 2021.6, we’ve added support for Read Preference Tags. This addition will be of great interest for many MongoDB Atlas users who want to make full use of workload-isolated Analytics nodes or want to target queries at MongoDB nodes in specific regions.

Atlas Tagged

MongoDB Atlas is very flexible. Among other things you can create clusters with geographically or cloud distributed nodes and nodes which are isolated from the operational workload. That means a cluster could have nodes on AWS and Azure, and that some of those nodes were specifically for analytics processing and shouldn’t be used for normal workloads.

MongoDB’s connection strings already have a lot of options, but they all map to the more general cases of things. Take Read Preference which when set in a connection string sets which kind of MongoDB node the connecting application should prefer. It can be set to primary, primaryPreferred, secondary, secondaryPreferred or nearest. That starts to give you control of which of the cluster’s nodes you connect to in the cluster without targeting specific IP addresses or DNS names.

For some users though that’s not precise enough. That’s why there’s Replica Set Tags. Think of them as a set of labels that nodes in a cluster can have attached to them. Each node in a cluster is given tags as part of the replica set configuration.

When a client looks to connect to the cluster some or all of those tags can be included in the connection string’s Read Preference Tags. These make the connection go to a node which matches those tags. If that all sounds a little abstract to you, let’s look at how Atlas uses Read Preference Tags.

Atlas’s Replica Set Tags

Atlas Nodes have tags for cloud provider (provider) which say which cloud provider the node lives on. There are tags for region (region) which say which cloud provider’s region the node resides in. And there are tags for types of node (nodeType) which say what kind of work the node is configured to do. There’s also a tag for selecting nodes which take part in the normal operational workload of the cluster (workloadType).

If you set your read preference to secondary and your read preference tags to:

{ "provider":"AWS", "region":"EU-WEST-2" }

Then the connection would attempt to find a secondary in Amazon’s EU-WEST-2 region – London.

If you set a read preference tag for node type to “ANALYTICS”:

{ "nodeType":"ANALYTICS" }

MongoDB Atlas would attempt to route your connection to one of the workload isolated analytics nodes in your cluster.

And if you set your read preference tags for workload type to “OPERATIONAL”:

{ "workloadType":"OPERATIONAL" }

your connections would be evenly routed amongst all the non-analytics nodes available in the cluster.

If your read preference is PRIMARY, none of this applies as there is only one primary node. But it does apply for all other read preferences when routing your connections to secondary nodes. Read preference tags are a powerful extra lever to control how your database resources are consumed.

In Studio 3T, you can set a connection’s read preference tags in the Connection Manager. Once you have selected anything but Primary in the Read Preference option for a replica set:

Editing Read Preference Tags in the Connection Manager


How helpful was this article?
This article was hideous
This article was bad
This article was ok
This article was good
This article was great
Thank you for your feedback!

About The Author

Dj Walker-Morgan

Dj has been around since Commodore had Pets and Apples grew everywhere. With a background in Unix and development, he's been around the technology business writing code or writing content ever since.

Related articles

  • What’s New in Studio 3T 2022.4 – Date Tags, Smarter Columns, Saving SQL Mappings
  • Date Tags
  • Date Tags: Getting It Right On DateTime
  • Mongosh: How To Read More Files 
  • Simplifying Data Migrations From Legacy SQL To MongoDB Atlas With Studio 3T And Hackolade

Tags

2022 academy aggregation AMA atlas Certification christmas community connections culture date tags events export features hackolade import intellishell In Use JSON knowledge base migration modelling mongodb mongoodb mongosh My 3T productivity query regex releases schema security SQL Studio 3T tasks time series tips updates webinar windows

Browse by MongoDB topic

  • Connecting to MongoDB
  • Database Administration & Security
  • Getting Started with MongoDB
  • Getting Started with Studio 3T
  • Import/Export
  • Job Automation & Scheduling
  • MongoDB Aggregation Framework
  • MongoDB/Studio 3T Workshops
  • Performance
  • Query & CRUD Operations
  • Reference
  • Schema
  • Studio 3T Licensing
  • Support and other resources
  • Working with MongoDB & SQL
  • Working with MongoDB Atlas

Studio 3T

MongoDB Enterprise Certified Technology PartnerSince 2014, 3T has been helping thousands of MongoDB developers and administrators with their everyday jobs by providing the finest MongoDB tools on the market. We guarantee the best compatibility with current and legacy releases of MongoDB, continue to deliver new features with every new software release, and provide high quality support.

Find us on FacebookFind us on TwitterFind us on YouTubeFind us on LinkedIn

Education

  • Free MongoDB Tutorials
  • Connect to MongoDB
  • Connect to MongoDB Atlas
  • Import Data to MongoDB
  • Export MongoDB Data
  • Build Aggregation Queries
  • Query MongoDB with SQL
  • Migrate from SQL to MongoDB

Resources

  • Feedback and Support
  • Sales Support
  • Knowledge Base
  • FAQ
  • Reports
  • White Papers
  • Testimonials
  • Discounts

Company

  • About Us
  • Blog
  • Careers
  • Legal
  • Press
  • Privacy Policy
  • EULA

© 2023 3T Software Labs Ltd. All rights reserved.

  • Privacy Policy
  • Cookie settings
  • Impressum

We value your privacy

With your consent, we and third-party providers use cookies and similar technologies on our website to analyse your use of our site for market research or advertising purposes ("analytics and marketing") and to provide you with additional functions (“functional”). This may result in the creation of pseudonymous usage profiles and the transfer of personal data to third countries, including the USA, which may have no adequate level of protection for the processing of personal data.

By clicking “Accept all”, you consent to the storage of cookies and the processing of personal data for these purposes, including any transfers to third countries. By clicking on “Decline all”, you do not give your consent and we will only store cookies that are necessary for our website. You can customize the cookies we store on your device or change your selection at any time - thus also revoking your consent with effect for the future - under “Manage Cookies”, or “Cookie Settings” at the bottom of the page. You can find further information in our Privacy Policy.
Accept all
Decline all
Manage cookies
✕

Privacy Preference Center

With your consent, we and third-party providers use cookies and similar technologies on our website to analyse your use of our site for market research or advertising purposes ("analytics and marketing") and to provide you with additional functions (“functional”). This may result in the creation of pseudonymous usage profiles and the transfer of personal data to third countries, including the USA, which may have no adequate level of protection for the processing of personal data. Please choose for which purposes you wish to give us your consent and store your preferences by clicking on “Accept selected”. You can find further information in our Privacy Policy.

Accept all cookies

Manage consent preferences

Essential cookies are strictly necessary to provide an online service such as our website or a service on our website which you have requested. The website or service will not work without them.

Performance cookies allow us to collect information such as number of visits and sources of traffic. This information is used in aggregate form to help us understand how our websites are being used, allowing us to improve both our website’s performance and your experience.

Google Analytics

Google Ads

Bing Ads

Facebook

LinkedIn

Quora

Hotjar

Reddit

Functional cookies collect information about your preferences and choices and make using the website a lot easier and more relevant. Without these cookies, some of the site functionality may not work as intended.

HubSpot

Social media cookies are cookies used to share user behaviour information with a third-party social media platform. They may consequently effect how social media sites present you with information in the future.

Accept selected