After the number of connections to an ApsaraDB for MongoDB instance reaches the limit, new connection requests cannot be responded. This topic describes how to handle database connection failures after the number of connections reaches the upper limit.
The maximum number of connections varies depending on ApsaraDB for MongoDB instance types. For more information, see Instance specifications.
- The application fails to connect to the database.
- The whitelist has been properly set. However, the following error message is displayed
when you use the mongo shell to connect to the database:
2019-07-10T10:30:43.597+0800 E QUERY [js] Error: network error while attempting to run command 'isMaster' on host 'dds-bpxxxxxxxx.mongodb.rds.aliyuncs.com:3717' : connect@src/mongo/shell/mongo.js:328:13 @(connect):1:6 exception: connect failed
- The whitelist has been properly set. However, the following error message is displayed when you use DMS to connect to the database.
Before you begin
To obtain the required monitoring information, we recommend that you set the monitoring granularity of the ApsaraDB for MongoDB instance to seconds. For more information, see Set the monitoring granularity.
Check whether the number of connections has reached the upper limit
- Log on to the ApsaraDB for MongoDB console.
- In the upper-left corner of the page, select the region of the instance.
- In the left-side navigation pane, click Replica Set Instances or Sharding Instances.
- Find the target instance and click its ID.
- In the left-side navigation pane, click Monitoring Info.
- On the Monitoring Info page, check the Connections information. The following figure shows that the number of connections to the instance
Note If the instance is a sharded cluster instance, you must select the Mongos node in use in the upper-right corner on the page.
- In the left-side navigation pane, click Basic Information.
- On the Basic Information page, query the maximum number of connections corresponding to the current instance
specifications. In this example, the number is 500.
Note Based on the number of current connections, you can confirm that the number of connections has reached the upper limit.
- Configure the connection pool. For more information, see How to query and limit the number of connections.
- Analyze the connection sources. For more information, see Query the source IP addresses of current connections. If the service uses all the connections, upgrade the instance specifications. For more information, see Configuration change overview.