The endpoints of an PolarDB cluster are classified into primary endpoints and cluster endpoints. To connect to an PolarDB cluster, you can use either a primary endpoint or a cluster endpoint of the PolarDB cluster. This topic describes the use scenarios of and differences between cluster endpoints and primary endpoints.

Comparison between cluster endpoints and primary endpoints

Endpoints
Endpoint type Description Scenario Supported network type
Cluster endpoint (recommended)
  • PolarDB provides read/write splitting. This feature enables PolarDB clusters to distribute read and write requests from applications by using cluster endpoints. The built-in proxy of a PolarDB cluster forwards write requests to the primary node, and forwards read requests to the primary node or read-only nodes based on the loads on nodes. The number of requests that are not processed on a node indicates the loads on the node.
  • An PolarDB cluster provides one cluster endpoint by default and allows you to create up to three cluster endpoints based on your business requirements. When you create a cluster endpoint, you can configure the read/write mode for the cluster endpoint and specify the nodes to which the cluster endpoint can connect.
  • To use the features of PolarProxy, you must use a cluster endpoint to connect to the PolarDB cluster. For more information about PolarProxy, see Database proxy.
Note PolarDB allows you to create single-node cluster endpoints. If the node that is associated with a single-node cluster endpoint becomes faulty, the single-node cluster endpoint becomes unavailable for up to 1 hour. We recommend that you do not use single-node cluster endpoints in your production environment.
  • Scenarios that require data isolation. You can use different cluster endpoints to connect your services to an PolarDB cluster based on your business requirements.
  • Cluster endpoints can be configured in one of the two read/write modes: read and write (automatic read/write splitting) and read-only. As a result, cluster endpoints can also be used for read-only services.

For example, you have purchased an PolarDB cluster that contains one primary node and four read-only nodes. You want to connect Service A and Service B to this cluster. Service A is a read-only service and Service B is a read/write service. You can create Cluster Endpoint a that runs in the read-only mode for Service A and associate Cluster Endpoint A with Read-only Node 1 and Read-only Node 2. Then, create Cluster Endpoint b that runs in read and write (automatic read/write splitting) mode for Service B and associate Custom Cluster Endpoint B with Read-only Node 3 and Read-only Node 4. This way, the data of Service A is physically isolated from the data of Service B.

  • Virtual private clouds (VPCs)
  • Internet
Primary endpoint
  • The primary endpoint allows you to connect to the primary node of the cluster. The primary endpoint can be used for read and write operations.
  • When the primary node is unavailable, the primary endpoint is switched to the new primary node.
Note You can modify only Network Information and Endpoint Name of a primary endpoint. Other parameters such as Node Settings, SLB Settings, and Consistency Settings cannot be modified. The procedure to modify the Endpoint Name of a primary endpoint is the same as that of a cluster endpoint. For more information, see Modify an endpoint.
Scenarios that do not require read/write splitting.

Private endpoints and public endpoints

Network type Description Scenario
VPCs
  • An PolarDB cluster achieves optimal performance when the cluster is connected by using a private endpoint.
  • When you create a cluster, a default private endpoint is provided. You can modify the endpoint but cannot delete it. For more information, see Modify an endpoint.
Examples:
  • If your Elastic Cloud Service (ECS) instance is deployed in the same virtual private cloud (VPC) as the cluster, your ECS instance can connect to the cluster by using the private endpoint.
  • You can use Data Management (DMS) to connect to clusters over VPCs.
Internet
  • You can apply for or delete a public endpoint. For more information, see Apply for a cluster endpoint or a primary endpoint.
  • A public endpoint allows connections over the Internet. An PolarDB cluster cannot achieve optimal performance when the cluster is connected by using a public endpoint.
For example, you can connect to your cluster by using a public endpoint to maintain databases.

Read/write modes for cluster endpoints

You can set the read/write mode to Read and Write (Automatic Read-write Splitting) or Read Only for a cluster endpoint. The following table describes the differences between cluster endpoints that use different read/write modes.

Note For more information about how to configure the read/write mode for a cluster endpoint, see Manage a cluster endpoint.
Item Read and Write (Automatic Read-write Splitting) Read Only
Associated nodes Nodes can be associated with the cluster endpoint in one of the following three configurations:
  • Only the primary node
  • One or more read-only nodes
  • The primary node and one or more read-only nodes
Note
  • Write requests are sent to only the primary node, regardless of whether the cluster endpoint in this mode contains the primary node.
  • For read requests, you can configure Primary Node Accepts Read Requests to specify whether the primary node processes read requests.
Nodes can be associated with the cluster endpoint in one of the following two configurations:
  • One or more read-only nodes
  • The primary node and one or more read-only nodes
Note
  • The read/write mode of a cluster endpoint that is associated with only the primary node cannot be set to Read Only.
  • Cluster endpoints in Read Only mode cannot be used to send write requests, regardless of whether the cluster endpoints are associated with only the primary node. You must connect to a cluster endpoint that runs in Read and Write (Automatic Read-write Splitting) mode to send write requests to the primary node.
Primary Node Accepts Read Requests Supported.

For more information, see Read/write splitting.

This feature is used to reduce the loads on the primary node. However, the primary node that is associated with an Read Only cluster endpoint does not process read or write requests. Therefore, this feature is unnecessary.
Transaction Splitting Supported.

For more information, see Transaction splitting.

Note This configuration is supported only if Consistency Level is Session Consistency (Medium) or Global Consistency (Strong).
This feature is used to reduce the loads on the primary node. However, the primary node that is associated with an Read Only cluster endpoint does not process read or write requests. Therefore, this feature is unnecessary.
Consistency Level Eventual Consistency (Weak), Session Consistency (Medium), and Global Consistency (Strong) are supported.

For more information, see Consistency levels.

This parameter is set to Eventual Consistency (Weak). The cluster endpoint in this mode does not process write requests.
Connection Pool Session-level and Transaction-level connection pools are supported.

For more information, see Connection pool.

Note
  • This connection pool feature is provided by PolarProxy of the PolarDB. This feature does not affect the connection pool feature in your clients. If the client provides a connection pool, you can set Connection Pool to Off in the PolarDB console to disable the connection pool feature of PolarProxy.
  • After you set Connection Pool to Off, PolarProxy sends a request from the client to all nodes that are associated with the cluster endpoint. These nodes include the primary node and the read-only nodes. The total number of available connections is limited by the maximum number of connections that can be established to the primary node.
Not supported.
Note PolarDB evenly distributes requests among all read-only nodes that are associated with the Read Only cluster endpoint. The primary node does not process requests. PolarProxy sends a request from the client to just a single node. The total number of available connections is equal to the total number of connections to all read-only nodes.
Parallel Query Not supported. The use of parallel query adversely impacts the primary node. Supported. For more information, see Parallel query.