To connect your application to a PolarDB cluster, you use an endpoint that contains a host address and a port provided in the connection string for any script, utility, or application. For most use cases, we recommend using the cluster endpoint for all connections to your cluster. This ensures your connections are highly available and automatically leverage the read-only nodes for scaling. For more specialized use cases, PolarDB also provides custom and primary endpoints. This guide describes the different types of endpoints and how to use them effectively.
Comparison between cluster endpoints and primary endpoints
Every PolarDB cluster has 3 types of endpoints, each designed for a specific use case. The Cluster and Custom endpoints are powered by the managed PolarProxy, which provides advanced features like read/write splitting, load balancing, and connection pooling.
Type | Description | Use cases | Supported network types |
Default cluster endpoint (Recommended) | A single endpoint that connects to the current primary node of the cluster. Provided by PolarProxy, it supports automatic read/write splitting. Write requests are routed to the primary node and read requests are routed to read-only nodes. | Businesses that require read/write splitting and can scale out quickly in real time by adding read-only nodes. |
|
Custom endpoint | A user-defined endpoint that connects to a specific subset of nodes within the cluster.
Note Single-node custom endpoints are intended for development or testing purposes only and should never be used in production. These endpoints provide no high availability. If the underlying node fails, the endpoint will become unavailable for up to one hour, causing an outage for any connected applications. | Isolating database node access for different services. For example, if read-only node 5 in the preceding figure fails, only Service Z is affected. By setting the read/write mode to Read-only, you can configure the endpoint to support only read-only services. | |
Primary endpoint | A single primary endpoint that connects to a specific database node, bypassing the PolarProxy.
| Businesses that do not require read/write splitting. |
Private and public endpoints
Endpoints can be configured with different network types to control access.
Network type | Description | Use cases |
Private network (VPC) |
| Examples:
|
Public network |
| For example, access the database cluster through a public endpoint for maintenance operations. |
Read/write modes for cluster endpoints
Cluster endpoints support two read/write modes: Read/Write (Automatic Read/Write Splitting) and Read-only. The following table describes the differences between the two modes.
For instructions on how to set the read/write mode for a cluster endpoint, see Configure PolarProxy.
Item | Read/Write (Automatic Read/Write Splitting) | Read-only |
Service node selection method | The following three methods are supported:
Note In read/write splitting mode:
| Only the following method is supported:
Note In read-only mode:
|
Load Balancing Policy | Supports the Active Request-based Load Balancing policy. | Connections-based Load Balancing and Active Request-based Load Balancing are supported. For more information, see Load balancing policy. |
Primary Node Accepts Read Requests | Supported. See Features for details. | This feature is not applicable because it is designed to reduce the load on the primary node. The primary node for a Read-only endpoint does not process any read or write requests. |
Transaction Splitting | Supported. Note This configuration is supported only if Consistency Level is set to Session Consistency (Medium) or Global Consistency (Strong). | This feature is not applicable because it is designed to reduce the load on the primary node. The primary node for a Read-only endpoint does not process any read or write requests. |
Consistency Level | Supports Eventual Consistency (Weak), Session Consistency (Medium), and Global Consistency (Strong). See Consistency level. | Only Eventual Consistency (Weak) is supported because this endpoint does not perform write operations. |
Connection Pool | Supports Session-level and Transaction-level connection pools. For more information, see Connection pool. Note
| Not supported. Note PolarDB evenly distributes connections among all read-only nodes that are configured for the Read-only cluster endpoint. The primary node does not participate in connection distribution. A client connection is routed through the proxy to a single read-only node. The total number of available connections is the sum of the maximum connections for all read-only nodes. |
Security Protection | Supported. See Overload protection. | Not supported. |