Promo Center

50% off for new user

Direct Mail-46% off

Learn More

Read-only nodes

Updated at: 2025-02-18 10:24

ApsaraDB for MongoDB provides read-only nodes that have an independent connection string Uniform Resource Identifier (URI) for an instance to offload read workloads from the primary and secondary nodes. Read-only nodes are suitable for direct connection to independent systems when primary and secondary nodes handle a large number of read requests.

In scenarios where a large number of read requests are received, primary and secondary nodes may be insufficient to handle read workloads and your business may be affected. In this case, you can create one or more read-only nodes based on your business requirements to handle a large number of database read requests. This increases application throughput.

Architecture

只读节点结构图

Read-only nodes have the following features:

  • Read-only nodes use oplogs to synchronize data from the primary or secondary node that has the lowest latency. Read-only nodes can be used to relieve read workloads on the primary and secondary nodes in business scenarios where a large number of read requests are received.

  • Read-only nodes have an independent connection string URI for an instance. Read-only nodes are suitable for direct connection to analysis program such as analysis servers. Read-only nodes do not interrupt the connections to existing primary and secondary nodes.

  • If your instance has two or more read-only nodes, you can use the read-only connection string URI to balance read requests received by the read-only nodes.

Differences between read-only nodes and secondary nodes

Node

Similarity

Difference

Scenario

Node

Similarity

Difference

Scenario

Read-only nodes

  • When a system or application connects to a database by using the endpoint of a read-only or secondary node, the system or application can only read data but cannot write data.

  • Read-only and secondary nodes provide high availability. If a node fails, the system automatically switch your business from the failed node to a healthy node. If the system does not perform the switchover, you can manually perform the switchover. The endpoints of the nodes remains unchanged during this process.

    Note

    For more information, see Switch node roles.

    Each time node roles are switched for an instance, the instance may encounter a 30-second transient connection. We recommend that you perform this operation during off-peak hours and make sure that your application can automatically reconnect to the instance.

  • Read-only nodes are not displayed in the alternative primary node list and cannot be elected as the primary node. Read-only nodes also do not participate in the primary node election process.

  • Read-only nodes have an independent connection string URI for an instance and are suitable for direct connection to independent systems and applications. Read-only nodes do not interrupt the connections to existing primary and secondary nodes.

If your instance has two or more read-only nodes, you can use the read-only connection string URI to balance read requests received by the read-only nodes. Read-only nodes are suitable for business scenarios where a large amount of data is read from an existing instance, such as business intelligence (BI) and big data analytics.

Secondary nodes

  • If the primary node fails, a secondary node can be elected as the new primary node to process read/write requests.

  • A secondary node has an independent connection string URI. However, the node may be elected as the new primary node when the original primary node fails. The system or application that directly connects to the new primary node may have write permissions.

Read/write requests can be separately processed by the primary and secondary nodes by using different connection string URIs. This improves instance performance and prevents node failures from affecting business. Secondary nodes are suitable for scenarios where the number of read requests is greater than the number of write requests.

Benefits

  • You can change the number of read-only nodes based on your requirements to reduce costs.

  • Read-only nodes have an independent connection string URI for an instance and are suitable for direct connection to independent systems. Read-only nodes do not interrupt the connections to existing primary and secondary nodes.

  • Read-only, primary, and secondary nodes have the same specifications. This allows read-only nodes to synchronize data from the primary or secondary node that has the lowest latency and eliminates maintenance needs.

  • Read-only nodes are independent nodes that provide only read services. The nodes do not compete for resources with primary nodes. If you change the number of read-only nodes in an instance, the primary and secondary nodes in the instance are not affected and connections to the primary and secondary nodes are not closed.

  • ApsaraDB for MongoDB provides a unified read-only connection string URI for replica set instances. You can use the URI to connect to all read-only nodes in a replica set instance. To extend database capabilities, you can add more read-only nodes without changing your application code.

    Note

    For more information, see Connect to a replica set instance.

Limits

  • Read-only nodes are available only for replica set and sharded cluster instances.

  • Read-only nodes handle only read requests and do not participate in election process for the primary node or the secondary nodes.

  • A maximum of five read-only nodes can be added to each replica set instance.

  • A maximum of five read-only nodes can be added to each shard of a sharded cluster instance.

  • Data is asynchronously replicated from the primary node or secondary nodes to read-only nodes. In most cases, a millisecond-level latency may exist during data replication. If the primary node has high write workloads, second-level latency may exist.

Pricing

The price of a read-only node is equivalent to that of a node in a replica set instance or that of a node in a shard of a sharded cluster instance.

  • On this page (1, T)
  • Architecture
  • Differences between read-only nodes and secondary nodes
  • Benefits
  • Limits
  • Pricing
Feedback
phone Contact Us

Chat now with Alibaba Cloud Customer Service to assist you in finding the right products and services to meet your needs.

alicare alicarealicarealicare