Connections in PolarDB-X 1.0 instances

Updated at:

This topic describes frontend and backend connections in PolarDB-X 1.0 instances.

Background information

When an application connects to a PolarDB-X 1.0 instance to execute operations, the PolarDB-X 1.0 instance supports the following two types of connections:

  • Frontend connection: A connection from an application to a logical database in a PolarDB-X 1.0 compute instance.
  • Backend connection: A connection from a compute node in a PolarDB-X 1.0 instance to a physical database in a backend PolarDB-X 1.0 storage instance (a private custom RDS instance).
1

Frontend connections

The number of frontend connections is theoretically limited only by the available memory and the number of network connections on the compute nodes of a PolarDB-X 1.0 instance. However, in common scenarios, an application that connects to a PolarDB-X 1.0 instance typically manages a limited number of connections to perform operations and does not maintain many concurrent persistent connections, such as tens of thousands. Therefore, the number of frontend connections that a PolarDB-X 1.0 instance can accept is considered unlimited.

Because the number of frontend connections is unlimited, many idle connections are allowed. This makes PolarDB-X 1.0 suitable for scenarios where many application servers are deployed and need to maintain simultaneous connections to an instance.

Although the number of frontend connections is theoretically unlimited, internal threads within the PolarDB-X 1.0 compute resource instance execute operation requests from these connections using backend connections. Because the number of internal threads and backend connections is limited, the overall concurrency for request processing in a PolarDB-X 1.0 instance is also limited.

Backend connections

Each compute node in a PolarDB-X 1.0 instance creates an internal backend connection pool. This pool automatically manages and maintains backend connections to the physical databases in the private custom RDS instance. Therefore, the maximum number of connections in the backend connection pool of a PolarDB-X 1.0 instance is directly related to the maximum connections supported by the private custom RDS instance. You can use the following formula to calculate the maximum connections for the backend connection pool in a PolarDB-X 1.0 instance.

Maximum connections for the PolarDB-X 1.0 instance backend connection pool = FLOOR(Maximum connections of the private custom RDS instance / Number of physical databases in the private custom RDS instance / Number of nodes in the PolarDB-X 1.0 instance)

For example, assume that a user purchases a private custom RDS instance and a PolarDB-X 1.0 instance with the following specifications.

  • One private custom RDS instance that contains eight physical databases. The instance is a General-purpose type with 4 cores and 16 GB of memory and supports a maximum of 4,000 connections.
  • One PolarDB-X 1.0 compute instance that is a Standard Edition with 16 cores and 64 GB of memory. Each 4-core, 16 GB unit is one node, so the instance has four nodes.

Based on the formula, you can calculate the maximum connections for the backend connection pool in the PolarDB-X 1.0 instance as follows.

Maximum connections for the PolarDB-X 1.0 instance backend connection pool = FLOOR(4000 / 8 / 4) = FLOOR(125) = 125
Note
  • The result calculated by the preceding formula is the upper limit for the maximum number of connections in the backend connection pool of the PolarDB-X 1.0 instance. In practice, a buffer is required to reduce the connection pressure on the private custom RDS instance. The PolarDB-X 1.0 instance adjusts the maximum number of connections in the backend connection pool to be lower than this upper limit.

  • You must create each database in a PolarDB-X 1.0 instance on a separate private custom RDS instance. Do not share one private custom RDS instance with other applications or other PolarDB-X 1.0 databases.

Relationship between frontend and backend connections

When an application establishes a frontend connection with a PolarDB-X 1.0 compute resource instance and sends an SQL statement, the nodes of the PolarDB-X 1.0 compute resource instance asynchronously process the request. The nodes obtain a backend connection from the internal backend connection pool to execute the optimized SQL statement on one or more physical databases.

The compute nodes of a PolarDB-X 1.0 instance use an asynchronous processing flow. Frontend and backend connections are not bound to each other. For typical short transactions and simple queries, a small number of backend connections can handle a large volume of requests from highly concurrent frontend connections. This is why you should focus on the queries per second (QPS) metric instead of the number of concurrent connections when you use PolarDB-X 1.0.

Although the number of frontend connections is considered almost unlimited, the maximum number of connections maintained by the backend connection pool on the compute nodes of a PolarDB-X 1.0 instance is limited. For more information, see Backend connections. Therefore, in common scenarios, you must note the following:

  • Avoid long-running transactions, also known as large transactions, in your application. If not committed or rolled back, these transactions can occupy backend connections for a long time. This can cause the backend connection pool to reach its limit, which reduces the overall concurrent processing capability and increases the response time.
  • You must monitor, optimize, or eliminate slow queries that run in PolarDB-X 1.0. These queries can occupy backend connections for extended periods, which causes the backend connection pool to become strained or reach its limit. In this situation, the PolarDB-X 1.0 compute instance or the private custom RDS instance faces increased processing pressure. This leads to a decrease in the overall concurrent processing capability and an increase in the response time. In critical cases, execution timeouts can also increase the failure rate of SQL statements.
Note If the number of backend connections still reaches the maximum limit of the backend connection pool in your PolarDB-X 1.0 instance during normal connection usage and query execution, contact us.