This topic describes how to configure PolarProxy, including how to enable features such as read/write splitting, transaction splitting, and consistency levels. You can configure these features by creating or modifying a cluster endpoint.
Scope of application
Configuring PolarProxy is currently not supported for PolarDB for PostgreSQL Distributed Edition clusters.
Create a custom cluster endpoint
Log in to the PolarDB console,In the navigation pane on the left, click Clusters. Select the Region where the cluster is deployed, and then click the cluster ID to go to the cluster details page。
On the Basic Information page, in the Database Connections section, click Create Custom Cluster Endpoint.
In the Create Custom Cluster Endpoint dialog box, configure the following parameters.
Parameter
Description
Network Information
PolarDB provides a private endpoint for each cluster endpoint by default. To modify the endpoint or apply for a public endpoint, see Modify an endpoint and Apply for an endpoint.
Cluster Settings
Read/Write
The read/write mode of this endpoint. Valid options are Read-only and Read/Write (Automatic Read/Write Splitting).
NoteYou can modify the read/write mode after the custom cluster endpoint is created. A modified read/write mode takes effect only on new connections. Existing connections retain the original mode.
Endpoint Name
Enter a name for the cluster endpoint.
Node Settings
Available Nodes and Selected Nodes
In the Available Nodes box on the left, select the nodes that you want to add to this endpoint to process read requests, and then click the
icon to move them to the Selected Nodes box on the right.NoteAvailable Nodes includes the primary node and all read-only nodes.
Node selection does not affect the read/write mode. When the read/write mode is Read/Write (Automatic Read/Write Splitting), write requests are sent only to the primary node regardless of whether the primary node is selected.
PolarDB allows you to create a cluster endpoint that contains only one node. However, when the read/write mode is Read-only, you are not allowed to create a single-node cluster endpoint that contains only the primary node.
Automatically Associate New Nodes
Specifies whether to automatically add newly added nodes to this endpoint.
Load Balancing Settings
Load Balancing Policy
When the read/write mode is Read-only, this is the scheduling policy for distributing read requests among multiple nodes. Valid options are Connections-based Load Balancing and Active Request-based Load Balancing.
When the read/write mode is Read/Write (Automatic Read/Write Splitting), this is the scheduling policy for distributing read requests among multiple nodes. The default is Active Request-based Load Balancing, and it cannot be changed.
Primary Node Accepts Read Requests
After this feature is enabled, query SQL statements are sent only to read-only nodes to reduce the load on the primary node and ensure the stability of the primary node. For more information about primary node protection, see Read/write splitting.
NoteThis configuration is supported only in the Read/Write (Automatic Read/Write Splitting) mode.
Transaction Splitting
Enables or disables transaction splitting. For more information about transaction splitting, see Transaction splitting.
NoteThis configuration is supported only when the read/write mode is Read/Write (Automatic Read/Write Splitting).
Consistency Settings
Consistency Level
When the read/write mode is Read/Write (Automatic Read/Write Splitting), valid consistency levels are Eventual Consistency (Weak), Session Consistency (Medium), and Global Consistency (Strong). For more information, see Consistency levels.
When the read/write mode is Read-only, the consistency level defaults to Eventual Consistency (Weak) and cannot be changed.
NoteA change to the consistency level takes effect immediately on all connections.
Global Consistency (Strong) is supported on PolarDB for PostgreSQL PostgreSQL 14 editions, and the kernel minor version must be 2.0.14.11.22.0 or later. For more information about this feature, see Global consistency.
Global Consistency Timeout
The timeout for waiting for read-only nodes to synchronize to the latest data in order to guarantee consistency. Valid values: 1 to 1000000. Unit: ms. Default value: 100.
NoteThis configuration is supported only when the Consistency Level is Global Consistency (Strong).
Global Consistency Timeout Policy
The execution policy when waiting for a read-only node times out. Valid values:
Send Requests to Primary Node (Default).
Return Error Messages Due to Timeout
Automatic Downgrade to Inconsistent Read Due to Timeout
NoteThis configuration is supported only when the Consistency Level is Global Consistency (Strong).
Connection Pool Settings
Connection Pool
You can select Off (default) or Transaction-level. You can use the transaction-level connection pool based on your business requirements to help reduce the database load caused by a large number of connections. For more information, see Transaction-level connection pool.
Click OK.
Modify a cluster endpoint
Log in to the PolarDB console,In the navigation pane on the left, click Clusters. Select the Region where the cluster is deployed, and then click the cluster ID to go to the cluster details page。
On the Basic Information page, in the Database Connections section, find the target cluster endpoint and click Configure on the right of the endpoint.
In the Modify Endpoint Settings dialog box, you can configure the related parameters.
Click OK.
Release a custom cluster endpoint
Only custom cluster endpoints can be released. The default cluster endpoint cannot be released.
A released custom cluster endpoint cannot be restored. Update the connection address on your client in a timely manner.
Log in to the PolarDB console,In the navigation pane on the left, click Clusters. Select the Region where the cluster is deployed, and then click the cluster ID to go to the cluster details page。
On the Basic Information page, in the Database Connections section, find the target custom cluster endpoint and click Release on the right of the endpoint.
In the dialog box that appears, click OK.
Related API operations
API |
Description |
Creates a custom cluster endpoint. |
|
Queries cluster endpoints. |
|
Releases a custom cluster endpoint. |