To meet data reading performance requirements in various business scenarios, you can change the number of primary and secondary nodes in a replica set instance in ApsaraDB for MongoDB. Data can be read from added secondary nodes. This method improves the overall read performance of replica set instances.

Background information

To ensure high availability of ApsaraDB for MongoDB, you can change the number of nodes in replica set instances to 3, 5, and 7.
Note You cannot change the number of nodes for a standalone instance.

You can add or remove nodes for a replica set instance, which must have at least three nodes. If you change the number of nodes for a replica set instance, the bill of the instance is changed. For more information, see Billing items and pricing.

Impacts

  • Configuration changes do not cause data loss.
  • Pre-operations for configuration changes to an instance do not affect the running of the instance. However, when configuration changes are formally executed on the instance, most operations of databases, accounts, and network cannot be performed. Transient connection error of up to 30 seconds may occur once or twice.
  • The duration of a configuration change is based on multiple factors such as network conditions, task queues, and data volume. We recommend that you change configurations during off-peak hours and make sure that your applications are configured with automatic reconnection policies.
  • To ensure better performance and stability of the instance, the system will upgrade the minor version to the latest version by default. If the minor version of your instance expires or is not included in the maintenance list and the instance is upgraded, migrated, changed, Created from a backup, Created by point-in-time, or performed Restore data to a new ApsaraDB for MongoDB instance.

Procedure

  1. Log on to the ApsaraDB for MongoDB console.
  2. In the upper-left corner of the page, select the resource group and the region of the target instance.
  3. In the left-side navigation pane, click Replica Set Instances.
  4. Find the target instance and click its ID.
  5. On the Basic Information page, perform the following steps based on the billing method of the instance:
    1. For a subscription instance, click Upgrade or Downgrade in the Basic Information section.
    2. For a pay-as-you-go instance, click Change Configuration in the Basic Information section.
  6. On the Configuration Upgrade page, specify Replication Factor for the instance.
    Specify the number of nodes
    Note For more information about how to change specifications and the storage space, see Configuration change overview.
  7. Read and select ApsaraDB for MongoDB Agreement of Service and complete the payment.

What to do next

After you add the nodes for the replica set instances, the connection strings of the new nodes that are all displayed as Secondary but with different role IDs appear in the console. The connection string URI for a high-availability connection is also updated. You can modify the connection string in an application to achieve high availability and read/write splitting connection to improve the overall performance. For more information, see Overview of replica set instance connections.