No. | Possible Cause | Troubleshooting Method | Solution |
1 | If a connection pool is used, a lot of connection resources may be used due to the unreasonable configuration of connection parameters. | Check whether the configuration parameters of the client connection pool are suitable for the business scenario. | Configure connection pool parameters as detailed below. |
2 | There are many connections without actual service requests on the business side. | Use DBbrain's performance optimization feature to check whether the connections from clients to the business are actually needed by the business on the Real-Time Session page. | Use
DBbrain's
performance optimization feature to directly kill unnecessary clients on the Real-time Session page. For detailed directions, see Performance Optimization. |
3 | There are a high number of slow queries that occupy connections. | 1. Use DBbrain's
performance optimization feature to query the records, execution statistics, and views of all current slow logs in the database on the Slow SQL Analysis page. For more information, see Performance Optimization. 2. Log in to the TencentDB for MongoDB console, click the instance ID to enter the Instance Details page, select the Database Management tab, click Slow Log Query, and select Query statistics to query slow queries. For detailed directions, see Slow Log Management. | For slow queries, perform index optimization. Use DBbrain's index recommendation feature to select the optimal index. Improve the database performance as instructed in Optimizing Indexes to Break Through Read/Write Performance Bottlenecks. |
4 | There are unreleased connections due to connection leaks. | Restart the instance. All instance connections will be interrupted at the moment of restarting mongos, but the business can be directly reconnected. Therefore, restarting mongos will not continuously affect the business. If the number of business connections increases rapidly and the connection utilization reaches 100% again after the restart, it indicates that the business does have a large number of valid connections and there are no connection leaks. For detailed directions, see Restarting Instance | Directly increase the number of connections in the console to temporarily sustain business surges. For detailed directions, see Connection Management. Adjust the instance configuration. For replica set instances, upgrading the CPU and memory specifications of mongod can increase the maximum number of connections of the instance. For more information, see Adjusting Mongod Node Specification. For sharded clusters, upgrade the mongos node specification or add more shards as instructed in Adjusting Mongos Node Specification or Adjusting Shard Quantity respectively. |
5 | The current instance quota becomes insufficient as the business surges. | Refer to item 2. | |
Parameter | Unit | Description | Configuration Suggestion |
maxPoolSize | - | Configure the maximum number of connections that each client can apply for in the connection pool. | The product of this parameter and the number of clients must be less than the maximum number of connections of the instance; otherwise, if there are excessive connections, new connections cannot be established. |
minPoolSize | - | Configure the minimum number of connections that each client can apply for in the connection pool. | The product of this parameter and the number of clients must be less than the maximum number of connections of the instance; otherwise, if many new connections need to be established during business surges, backend instance resources will become insufficient. |
socketTimeoutMS | ms | Configure the wait timeout period for sending and receiving sockets. The default value is 0 , indicating not to time out. | Set this parameter according to your actual business scenario so as to avoid that when a MongoDB server failure causes a primary/secondary switch, the client will not be able to receive the packet of the server response, resulting in prolonged use of resources by this invalid connection. |
maxIdleTimeMS | ms | Configure the maximum time an idle connection exists before it is deleted or closed. | Set this parameter to be within 1 hour to avoid idle connections occupying connection resources all the time. |
heartbeatFrequencyMS | ms | Configure the frequency at which the client sends heartbeats to the server. This parameter is used by the client to periodically check the status of the connection to the backend database. | Set this parameter to be within 10s, so that the status of the server can be checked as soon as possible to avoid generating invalid connections. |
Was this page helpful?