tencent cloud

TencentDB for MongoDB

Release Notes and Announcements
Release Notes
Announcements
User Guide
Product Introduction
Overview
Strengths
Use Cases
Cluster Architecture
Product Specifications
Features
Regions and AZs
Terms
Service Regions and Service Providers
Purchase Guide
Billing Overview
MongoDB Pricing
Billing Formula
Payment Overdue
Backup Space Billing
Configuration Adjustment Billing
Getting Started
Quickly Creating an Instance
Connecting to a TencentDB for MongoDB Instance
Reading/Writing Database
Operation Guide
Access Management
Instance Management
Node Management
Version Upgrade
Network Configuration
Monitoring
Backup and Rollback
Database Audit
Data Security
SSL Authentication
Log Management
Database Management
Multi-AZ Deployment
Disaster Recovery/Read-Only Instances
Parameter Configuration
Recycle Bin
Task Management
Performance Optimization
Data Migration Guide
Practical Tutorial
Optimizing Indexes to Break Through Read/Write Performance Bottlenecks
Troubleshooting Mongos Load Imbalance in Sharded Cluster
Considerations for Using Shard Clusters
Sample of Reading and Writing Data in MongoDB Instance
Methods for Importing and Exporting Data Based on CVM Connected with MongoDB
What to Do for Errors of Repeated Instance Creation and Deletion of Databases with the Same Names?
Troubleshooting MongoDB Connection Failures
Shard Removal Task: Guide for Confirming the Progress and Troubleshooting Issues
Performance Fine-Tuning
Ops and Development Guide
Development Specifications
Command Support in Sharded Cluster v3.2
Command Support in v3.6
Development Ops
Troubleshooting
Increased Slow Queries
Number of Connections Exceeding Limit
API Documentation
History
Introduction
API Category
Making API Requests
Instance APIs
Backup APIs
Account APIs
Other APIs
Task APIs
Introduction
Data Types
Error Codes
Instance Connection
Shell Connection Sample
PHP Connection Sample
Node.js Connection Sample
Java Connection Sample
Python Connection Sample
Python Read/Write Sample
Go Connection Sample
PHP Reconnection Sample
Product Performance
Test Environment
Test Method
Test Result
FAQs
Cost
Features
Sharded Cluster
Instance
Rollback and Backup
Connection
Data Migration
Others
Service Agreement
Service Level Agreement
Terms of Service
Glossary
Contact Us

Enabling SRV Connection Mode

PDF
Focus Mode
Font Size
Last updated: 2026-01-08 18:00:28

Scenarios

TencentDB for MongoDB provides the SRV connection mode, which is an automatic load balancing solution based on DNS services. A simple connection string is used to automatically resolve the addresses of all currently available Mongos nodes or replica set members, enabling automatic load balancing and high availability failover for clients. This significantly simplifies connection configuration and management in multi-node cluster environments.
Application Scenario
Description
Dynamic connection to a sharded cluster
An SRV connection string can be used to automatically discover and return a list of all available Mongos nodes without requiring manual maintenance of node IP addresses. This enables automatic load balancing and high availability during cluster scaling or in case of node failures, significantly enhancing Ops efficiency and system elasticity.
Simplified replica set connection
An SRV connection string can be used to obtain the complete topology information of the replica set in a single step. Clients no longer need to list all node addresses, enabling faster and more convenient reconnection to the new primary node during primary node failover. This significantly reduces service interruption time and ensures service continuity.

Notes

Type
Support Status
Version
Version 4.0 and later
Instance type
Sharded cluster instances and replica sets support this mode.
Instance specifications
Both Physical Disk Edition and Cloud Disk Edition support this mode.
Note:
During network switch, SRV address resolution may take approximately 5 minutes to update.
After the SRV address is updated, the local DNS cache may become invalid, preventing connection to the instance via the SRV address. In this case, you can proactively flush the DNS cache to promptly restore connectivity.

Operation Steps

2. In the MongoDB drop-down list on the left sidebar, select Replica Set Instance or Shard Instance. The directions for the two types of instances are similar.
3. Above the Instance List on the right, select the region.
4. In the instance list, find the target instance.
In the search box in the top-right corner, you can search for the target instance by instance ID, instance name, private IP, or tag key.
If the instance is not found in the instance list, select Recycle Bin on the left sidebar to check whether it is isolated there due to overdue payments. For more information, see Recycle Bin.
5. In the Instance ID/Name column of the target instance, click the Instance ID to enter the Instance Details page.
6. In the Network Configuration section on the Instance Details page, click Enable SRV Connection Mode next to SRV Access Address.

7. A small window showing Enable SRV Connection Mode appears. Read the activation instructions and precautions as shown in the following figure, and click OK.

8. After the task is completed, the SRV access address is shown in the Network Configuration section on the Instance Details page, as shown in the following figure.

9. (Optional) Click Modify Connection Address to change the prefix of the SRV connection address according to the instructions, allowing you to distinguish instances in different scenarios using distinct prefixes.


Help and Support

Was this page helpful?

Help us improve! Rate your documentation experience in 5 mins.

Feedback