Scenarios
When your business encounters sudden traffic spikes in scenarios such as e-commerce promotions and hot events, a large volume of concurrent requests may cause database instances to reach performance bottlenecks due to an insufficient number of connections. This specifically manifests as client connection failures, application errors, or slow response times. At this time, you can go to the TencentDB for MongoDB monitoring page and check the "current number of connections" metric. If the value persistently approaches or reaches the upper limit of the instance specification, the limit is considered the bottleneck. To quickly meet these requirements and ensure continuous and stable business operation, you can directly increase the value of the"maximum number of connections" in the console. This temporary scale-out approach helps alleviate connection pool pressure quickly, supporting the stable operation of the business during peak periods.
Version Description
Replica set: All MongoDB versions support management of the number of connections.
Sharded cluster: It is not supported in MongoDB 4.2, but is supported in all other versions.
Connection Number Management and Guide
When the system detects a high number of connections to an instance, you can follow the steps below for troubleshooting to ensure the stable operation of the business.
|
1 | Connection monitoring and manual intervention | The system will log all client IP addresses connected to the instance, along with their respective number of connections. If any abnormal sources are detected or urgent resource release is required, you can interrupt specific connections manually. |
2 | Dynamic increase in the number of connections | If the current connection utilization reaches 80% or above continuously and impacts the establishment of new connections, you can use the "one-click increase in the number of connections" feature in the console to temporarily increase the connection upper limit to 150% of the original specification within 6 hours, quickly meeting business requirements during peak periods. |
3 | Asking for further support | If the temporary increase of the number of connections still cannot meet the business requirements, contact after-sales staff or submit a ticket for handling. |
4 | Long-term optimization suggestions | Instance specification upgrade: If connection number bottlenecks occur frequently, it is recommended to plan an instance upgrade to a higher specification to improve the concurrency processing capability fundamentally. Connection management optimization: Perform optimizations on the application side, such as using a database connection pool and disabling idle connections promptly to improve connection utilization. |
Prerequisites
The status of the replica set instance or sharded cluster instance of TencentDB for MongoDB is Running.
For sharded cluster instances, confirm that the TencentDB for MongoDB version is not 4.2.
Viewing Connection Number Usage
2. In the left sidebar, expand the MongoDB dropdown list, and select either Replica Set Instance or Shard Instance. The operations for replica set instances and sharded cluster instances are similar.
3. Select a region at the top of the instance list page on the right.
4. Find the target instance in the instance list.
5. Click the target instance ID to go to the Instance Details page.
6. Select the Database Management tab, and select the Manage Connection tab.
7. View connection statistics for all clients in the current database.
|
Real-time connections | Statistics on the number of connections in the current database. |
Connection Utilization | Percentage of the number of connections for all clients in the current database to the maximum number of connections. |
Max connections | Upper limit of the number of connections. |
Remaining | Increases the remaining usage time of connections. |
Client IP | Client IP address for database connection. |
Connections | Connection number statistics. |
Increasing the Number of Connections
When the number of connections for the current instance exceeds 80% of the maximum number of connections, you can increase the maximum number of connections temporarily.
1. On the Manage Connection page, click Increase Connections.
2. In the Prompt dialog box, confirm the prompt message, and click OK.
Related APIs
|
DescribeClientConnections | |