tencent cloud

Feedback

Creating Read-Only Instances

Last updated: 2024-05-07 12:52:26

    Scenario Description

    In application scenarios with a small amount of write requests but a large number of read requests, a single instance may not withstand the reading pressure, and may even impact the core business. You can create one or more new read-only instances in the source instance's availability zone or other availability zones based on the current instance's cluster architecture and storage engine. This shifts the read requests from the current instance to the read-only instances, achieving elasticity in read capability, enhancing read/write performance, and increasing the application's throughput.

    Notes

    Due to data synchronization delays, the real-time performance of data synchronization in read-only instances might not be guaranteed. If the business requires read-write separation and has high real-time requirements, it is recommended to read from the secondary node of the primary instance. The synchronization latency between each read-only instance and the primary instance can be checked on the console.
    The connection method for the read-only instance is the same as that of the primary instance. See Connecting to MongoDB Instance.
    During the lifecycle of a read-only instance, it can only perform read operations and cannot execute data write or update operations.
    Read-only instances do not support manual disconnection from the source instance. They are automatically disconnected from the source instance only when the source instance is terminated. The read-only instance then becomes a standard instance, capable of normal reading and writing.

    Version Description

    The current MongoDB versions 3.2, 3.6, 4.0, 4.2, 4.4, and 5.0 support the creation of read-only instances for replica set instances. Sharded instances are supported only in versions 4.0 and above.

    Prerequisites

    The current instance is operating normally but with a high read request volume and significant latency, leading to slow database performance. For more information, see Monitoring Overview.
    The availability zone for the read-only instance and its associated network have been planned.
    The storage specifications and purchase quantity for the read-only instance have been estimated.
    The billing model has been selected based on the business scenario, and the costs associated with the read-only instance have been budgeted.

    Creating Read-Only Instance

    1. Log in to the MongoDB console.
    2. On the left sidebar, choose NoSQL > MongoDB.
    3. In the MongoDB drop-down list, select Replica Set Instance or Sharded Cluster. The operations for replica sets and sharded clusters are similar.
    4. Above the instance list on the right, select the region.
    5. In the instance list, find the target instance.
    6. Click the target instance ID to enter the Instance Details page.
    7. Select the Read-Only Disaster Recovery tab to access the Read-Only Instance page.
    8. On the Read-Only Instance page, click Create.
    9. On the TencentDB for MongoDB Read-Only Instance purchase page, confirm the Primary Instance Information and select the required configuration.
    
    See the table below to configure the instance specifications based on your actual needs.
    Parameter Name
    Parameter Description
    Billing Mode
    Monthly subscription and pay-as-you-go billing are supported. For how to choose a billing mode, see Billing Overview.
    Region
    The region of the read-only instance is fixed and matches that of the source instance. It cannot be changed.
    Availability Zone
    Select whether to enable multiple availability zone deployment. Settings can be adjusted based on actual highly available business requirements.
    Database Version
    The database version is fixed and matches that of the source instance. It cannot be changed.
    Architecture Type
    The architecture type is fixed and matches that of the source instance. It cannot be changed. For specific information about the architecture type, see System Architecture.
    Storage Engine
    The default storage engine is WiredTiger.
    Mongod Specification
    Select the compute specifications for the database instance from the dropdown list. The CPU core number and memory capacity of a read-only instance must be equal to or greater than those of the source instance, with higher specifications resulting in higher IOPS. For specific supported specifications, see Product Specification.
    After creating an instance, you can adjust its compute specifications. For specific operations, see Adjusting Instance Configuration.
    MongoDB Shard Quantity
    When the architecture type is set to Sharded Cluster, this parameter is displayed. It is used for setting the number of shards in the sharded cluster, with a value range of [1,20]. The shard quantity of a read-only instance must be greater than or equal to that of the source instance. Each shard is a replica set. Increasing the shards quantity can enhance the cluster's storage capacity. Select as needed.
    After creating an instance, you can adjust the MongoDB shard quantity. For specific operations, see Adjusting Instance Configuration.
    Disk Capacity
    Select the database instance's storage capacity on the slider. The disk capacity of a read-only instance must be greater than or equal to that of the source instance. MongoDB specifications differ, hence the range of disk capacities varies. See Product Specification. The system by default allocates 10% of the selected storage capacity for Oplog's storage space. The size of Oplog can be adjusted in the console instance list. For specific operations, see Adjusting Oplog Storage Capacity.
    After creating an instance, you can adjust the instance's disk capacity. For specific operations, see Adjusting Instance Configuration.
    Primary/Secondary Nodes Quantity
    When the architecture type is set to replica set, this parameter is displayed. The default is 3 nodes (1 primary, 2 secondaries), with three storage nodes forming a one-primary-two-secondary architecture. Custom replication numbers are not currently adjustable. You may select from the dropdown list: 5 nodes (1 primary, 4 secondaries), or 7 nodes (1 primary, 6 secondaries).
    After creating a read-only instance, you can increase the number of secondary nodes. For specific operations, see Adding Secondary Node.
    Primary/Secondary Nodes Quantity per Shard
    When the architecture type is set to Sharded Cluster, this parameter is displayed. It is used for setting the number of nodes in each shard of the sharded cluster, with the default being 3 nodes (1 primary, 2 secondary nodes), meaning each shard follows a one-primary-two-secondary, three-node architecture. You can select from the dropdown list: 5 nodes (1 primary, 4 secondary nodes), or 7 nodes (1 primary, 6 secondary nodes). Custom node numbers are not currently supported. After creating the instance, you can increase the number of secondary nodes per shard. For specific operations, see Adding Secondary Node.
    Read-Only Node Quantity
    Setting the number of read-only nodes, supporting 0 to 5 read-only nodes. Only versions 4.0 and 4.2 support configuring the number of read-only nodes; version 3.6 does not support this.
    After creating a read-only instance, you can increase the number of read-only nodes. For specific operations, see Adding Read-Only Node.
    Configuration Instructions
    Based on the configured MongoDB specification, calculate the maximum number of connections per instance to help you predict whether the current specification meets expectations.
    Mongos Specifications
    When the architecture type is set to Sharded Cluster, this parameter is displayed. It is used for configuring Mongos specifications. After configuring the MongoDB specification, Mongos will have default specification configurations. For example, if MongoDB is set to 2-core 4GB, Mongos is automatically configured for 1-core 2GB by default. Upgrading the Mongos specification will incur charges. For pricing, see Product Pricing. The connection limit for a sharded cluster will be determined by the Mongos specifications and quantities you choose. You can view the maximum number of connections in the Configuration Instructions.
    After creating an instance, you can change the Mongos configuration. For specific operations, see Changing Mongos Node Configuration Specifications.
    Mongos Quantity
    When the architecture type is set to Sharded Cluster, this parameter is displayed. It is used for configuring the number of Mongos. If the instance deployment is in the same availability zone, the range of Mongos numbers is [3, 32]. If the multi-availability zone deployment is enabled and the instance deployment is across different availability zones, then the range of Mongos numbers is [6, 32]. Increasing the number of Mongos will incur charges. For pricing, see Product Pricing.
    After creating an instance, you can adjust the number of Mongos. For specific operations, see Add New Mongos Node.
    Network Type
    Only Virtual Private Cloud is supported.
    IPv4 Network
    Select a specific Virtual Private Cloud and its subnet. It is recommended to select the same Virtual Private Cloud in the same region as the cloud server. A Virtual Private Cloud has a region attribute (e.g., Guangzhou), while a subnet has an availability zone attribute (e.g., Guangzhou Zone 1). A Virtual Private Cloud can be divided into one or more subnets. Subnets under the same Virtual Private Cloud are by default inter-connected through intranet, whereas Virtual Private Clouds (whether in the same region or not) are by default isolated from each other.
    After purchasing an instance, you can switch the Virtual Private Cloud. For specific operations, see Switch Instance Network. You can also click Create a New Virtual Private Cloud and Create a New Subnet to recreate the required network environment. For specific operations, see Creating Virtual Private Cloud.
    IPv6 Network
    Enable/disable IPv6 access. Currently not supported.
    Security Group
    Set security group rules for the instance to control inbound traffic to the database. You can select an existing security group from the dropdown menu, or click Custom Security Group to set new inbound rules for the security group. For detailed information, see Configuring Security Group.
    Specify Project
    Allocate the instance to the corresponding project. You can manage instances by project.
    Tag
    Set tags for your instance. You can classify and manage instances based on tags. Click Add to select tag keys and values.
    Instance Name
    Set the instance name, with a default of 500. Set a recognizable name.
    Supports Chinese, English, and numbers with a length less than 60, including hyphens "-" and underscores "_".
    Purchase Quantity
    A single instance can support up to 3 read-only instances.
    Purchase Period
    When choosing monthly subscription, you need to select the purchase duration of the instance. The longer the duration, the greater the discount. You can choose according to your actual business needs.
    Total Fees
    Pay-as-you-go, displaying the hourly cost. Click Billing Details, and see Product Pricing.
    10. Confirm that the configuration is correct, click Purchase Now. After the purchase is successful, click Go to Console. In the instance list, once the instance status shows as Running, it can be used normally.

    Viewing Read-Only Instance

    View the source instance from the read-only disaster recovery page.
    1. Log in to the MongoDB console.
    2. In the MongoDB drop-down list on the left sidebar, select Replica Set Instance or Sharded Instance. The operations 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 source instance of the read-only instance.
    You can search for the target instance by entering the instance ID, instance name, private network IP or tag key in the search box in the upper right corner of the instance list.
    If the instance is not found in the instance list, select Recycle Bin from the left sidebar to confirm whether the instance has been isolated in the recycle bin due to expiration of fees. For more information, see Recycle Bin.
    5. In the Instance ID / Name column of the source instance, click the instance ID to enter the Instance Details page.
    6. Click the Read-Only Disaster Recovery tab and select the Read-Only Instance tab.
    
    7. View all the read-only instances under the source instance.
    Parameter
    Parameter Description
    Instance ID
    Read-only instance ID and its name. Click the instance ID in blue font to jump to the read-only instance details page. For more information, see Viewing Instance Details.
    Status
    The current running status of the instance. When it is normal, it should be Running.
    Specification
    Instance specification information. It includes memory and disk capacity.
    Latency
    The read-only instance is based on the synchronization status from the source instance, and its latency.
    Nodes Quantity
    The number of primary and secondary nodes in a read-only instance.
    Network
    The name of the Virtual Private Cloud to which the read-only instance belongs.
    Private Network Address
    The private IPv4 address assigned by the Virtual Private Cloud. When accessing the database, the private IP address and its port information need to be configured. For specific operations, see Connecting to MongoDB Instance.
    Region
    Information about the region and availability zone.
    Deadline
    With monthly subscription, it displays the specific time point of the instance expiration. It is empty for pay-as-you-go billing.
    Operation
    By clicking configuration changes, you can adjust the specifications of the read-only instance. When adjusting the specifications of the source instance, be sure to synchronously upgrade the specifications of the read-only instance; otherwise, data loss may occur.
    Contact Us

    Contact our sales team or business advisors to help your business.

    Technical Support

    Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

    7x24 Phone Support