PolarProxy serves as a proxy between a database and an application in a PolarDB cluster. PolarProxy receives and routes all the requests from the application. PolarProxy supports advanced features, such as automatic read/write splitting, load balancing, consistency levels, and connection pools. PolarProxy is easy to use and maintain, and provides high-availability and high-performance services. You can connect to PolarDB cluster endpoints to use the features of PolarProxy.

PolarProxy features

1

A PolarDB cluster of Cluster Edition consists of a primary node and two or more read-only nodes. By default, PolarDB provides two types of endpoints: the primary endpoint and cluster endpoints. PolarProxy provides cluster endpoints for PolarDB. Cluster endpoints include read/write endpoints and read-only endpoints. Read/write endpoints support read/write splitting. Read-only endpoints allow PolarDB clusters to distribute read requests to read-only nodes based on the number of connections.

Pricing

PolarProxy of PolarDB is free of charge. The free edition and Enterprise Edition of PolarProxy will be available in the future. Enterprise Edition will provide better enterprise-grade service capabilities than the free edition.

Limits

Only PolarDB clusters of Cluster Edition support cluster endpoints and PolarProxy. PolarDB clusters of the Single node and Archive database editions use a single-node architecture, and do not support PolarProxy and cluster endpoints.

Precautions

  • PolarProxy does not support compression protocols for the default and custom cluster endpoints.
  • If you do not enable the transaction splitting feature after cluster endpoints are used, all the requests in a transaction are forwarded to the primary node.
  • When you execute the SHOW PROCESSLIST statement after cluster endpoints are used, the system returns the results of all the nodes.
  • If you execute multi-statements or call stored procedures, all subsequent requests for the current connection are forwarded to the primary node. For more information, see Multi-statement. To use the read/write splitting feature, you must close the current connection and reconnect to the cluster.
  • The maximum number of connections to a PolarDB cluster endpoint depends on the specifications of compute nodes in backend databases.
  • If a session that supports read/write splitting is created after you add or restart a read-only node, read requests are forwarded to the read-only node. If a session that supports read/write splitting is created before you add or restart a read-only node, read requests are not forwarded to the read-only node. To forward these read requests to the read-only node, you must close the connection and reconnect to the cluster. For example, you can restart your application to establish a new connection.
  • Do not modify environment variables when you call stored procedures or execute multi-statements, such as set names utf8mb4;select * from t1;. Otherwise, data inconsistency occurs when read requests are sent to read-only nodes and the primary node.

Read/write splitting

PolarDB clusters of Cluster Edition support read/write splitting. This feature allows a PolarDB cluster to distribute read and write requests from applications by using a cluster endpoint. Write requests are forwarded to the primary node. Read requests are forwarded to the primary node or read-only nodes based on the loads on each node. The number of pending requests on a node indicates the loads on the node. For more information, see Read/write splitting.

Load balancing

PolarDB supports automatic distribution based on the loads of nodes. Read requests are automatically forwarded to read-only nodes based on the number of active connections. This ensures load balancing among read-only nodes. Load balancing allows you to offload reads from the primary node to read-only nodes and split transactions.
  • Primary Node Accepts Read Requests

    SQL statements are sent to read-only nodes when data consistency and transaction correctness are achieved. This reduces the loads on the primary node and makes the primary node stable. For more information, see Offload reads from the primary node.

  • Transaction Splitting

    PolarDB supports transaction splitting. This feature ensures data consistency in a session and allows PolarDB to send read requests to read-only nodes. This reduces the loads on the primary node. For more information, see Split transactions.

Consistency levels

PolarDB asynchronously replicates the updates from the primary node to read-only nodes. In read/write splitting mode, a read request that follows a write request may fail to obtain the latest data. This causes data inconsistency. PolarDB provides the eventual consistency, session consistency, and global consistency options. For more information, see Consistency levels.

Connection pools

PolarDB supports session-level connection pools and transaction-level connection pools. You can select a connection pool based on your business requirements to reduce the database loads caused by a large number of connections. For more information, see Connection pool.

Persistent connection

PolarDB supports the persistent connection feature to prevent network interruptions or temporary failures for new connections. These issues may be caused by O&M operations, such as configuration upgrades, primary/secondary switchovers, and minor version upgrades. Issues may also be caused by other errors. For example, the server where nodes are deployed is unavailable. This new feature further improves the high availability of PolarDB. For more information, see Persistent connection.

Parallel query

The parallel query feature is a parallel query framework that is released in ApsaraDB PolarDB MySQL-compatible edition 8.0. PolarDB enables the framework based on database costs and rules. For more information, see Parallel query.

Dynamic data masking

When your application initiates a data query request, PolarDB masks the sensitive data that is queried before PolarDB returns the data to the application. To achieve this, you need to specify the database account and name and the table or column that requires data masking before the data is queried. For more information, see Dynamic data masking.

Related operations

API Description
CreateDBEndpointAddress Creates a public endpoint for a specified PolarDB cluster.
CreateDBClusterEndpoint Creates a custom cluster endpoint for a specified PolarDB cluster.
DescribeDBClusterEndpoints Queries the information about the endpoints of a specified PolarDB cluster.
ModifyDBClusterEndpoint Modifies the configurations of a cluster endpoint for a specified PolarDB cluster.
ModifyDBEndpointAddress Changes the endpoints of a specified PolarDB cluster, such as a custom cluster endpoint.
DeleteDBEndpointAddress Deletes a cluster endpoint of a specified PolarDB cluster. The cluster endpoints that can be deleted include the primary endpoint, the default cluster endpoint, and a custom cluster endpoint. Each type of cluster endpoint has a private endpoint and a public endpoint. You cannot delete the private endpoint of a custom endpoint.
DeleteDBClusterEndpoint Deletes a custom cluster endpoint of a specified PolarDB cluster.