To connect to a PolarDB cluster, you must use an endpoint of the PolarDB cluster. PolarDB supports cluster endpoints and the primary endpoint. For each type of endpoint, you can apply for a virtual private cloud (VPC)-facing endpoint or a public-facing endpoint to connect to the cluster. This topic describes how to view or apply for an endpoint in the console.

Cluster endpoints and the primary endpoint

Endpoints
Endpoint Description Supported network
Cluster endpoint (recommended)
  • An application can connect to multiple nodes of a cluster by connecting to only one cluster endpoint.
  • Cluster endpoints support read/write splitting. 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.
Note A PolarDB cluster provides a default cluster endpoint. You can create one or more custom cluster endpoints. When you create a custom cluster endpoint, you can specify the nodes that can be connected through the endpoint and set the read/write mode. For more information, see Cluster endpoint.
  • Internal network
  • 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 For primary endpoints, you can modify only the Network Information section and the Endpoint Name field. You cannot modify the configurations of the Node Settings, SLB Settings or Consistency Settings. Steps to modify primary endpoints names are the same as those of modifying cluster endpoint names. For more information, see Modify a cluster endpoint.

VPC-facing endpoints and public-facing endpoints

Network Description Scenario
Internal network
  • A PolarDB cluster achieves optimal performance when the cluster is connected through a VPC-facing endpoint.
  • When you create a cluster, a default VPC-facing endpoint is provided. You can modify the endpoint, but cannot delete it. For more information, see Modify an endpoint and port number.

Examples:

  • Your Elastic Compute Service (ECS) instance can connect to your PolarDB cluster through a VPC-facing endpoint if they are deployed in the same VPC.
  • You can connect to your PolarDB cluster over the VPC by using Data Management (DMS).
Internet
  • You can apply for or delete a public-facing endpoint. For more information, see Apply for an endpoint and Delete an endpoint.
  • The public-facing endpoint enables connections over the Internet. A PolarDB cluster cannot achieve optimal performance when the cluster is connected through a public-facing endpoint.
For example, you can connect to your PolarDB cluster through a public-facing endpoint to maintain databases.

View an endpoint and port number

  1. Log on to the PolarDB console.
  2. In the upper-left corner of the console, select the region where the cluster is deployed.
  3. Find the cluster and click the cluster ID.
  4. In the Endpoints section of the Overview page, you can view an endpoint and port number by using the following methods:
    • Method 1

      Click the Switch views icon in the upper-right corner of the Endpoints section to switch views. Then, you can view the endpoint and port number in the list view.

      E
    • Method 2

      Click Modify on the right of the cluster endpoint. In the dialog box that appears, you can view the endpoint and port number in the Network Information section.

      2
    Note
    • If you use a domain name to connect to a database, you can click Bind Private Domain to bind the domain name to a VPC-facing endpoint. This allows you to retain the original database domain name after the database is migrated to the cloud. Only VPC-facing Endpoint endpoints can be bound to the private domain name. For more information, see Private domain names.
    • The default port number for an endpoint of a PolarDB for MySQL cluster is 3306. You can modify the port number. For more information, Modify an endpoint and port number.

Apply for an endpoint

  1. Log on to the PolarDB console.
  2. In the upper-left corner of the console, select the region where the cluster is deployed.
  3. Find the cluster and click the cluster ID.
  4. In the Endpoints section of the Overview page, you can apply for an endpoint by using the following methods:
    • Method 1:
      1. Click the Switch views icon in the upper-right corner of the Endpoints section to switch views.
      2. Click Apply. 2
    • Method 2:
      1. Click Modify on the right of the cluster endpoint.
      2. In the dialog box that appears, click Apply in the Network Information section. 2
    Note You can apply for only Public-facing Endpoint endpoints. After you create a cluster, a default VPC-facing Endpoint endpoint is provided. You do not need to apply for this endpoint.
  5. In the dialog box that appears, specify a prefix for the endpoint and click OK.
    Note The prefix of the endpoint must meet the following requirements:
    • It must be 6 to 30 characters in length, and can contain lowercase letters, digits, and hyphens (-).
    • It must start with a letter and end with a digit or a letter.

What to do next

Connect to a PolarDB for MySQL cluster

FAQ

Am I charged for the data transfer if my application uses a public-facing endpoint to connect to PolarDB?

No, you are not charged for the data transfer incurred by PolarDB public-facing endpoints.

Related API operations

API Description
DescribeDBClusterEndpoints Queries the endpoints of a specified PolarDB cluster.
CreateDBEndpointAddress Creates public-facing endpoints for a specified PolarDB cluster.
ModifyDBEndpointAddress Modifies the endpoints of a specified PolarDB cluster.
DeleteDBEndpointAddress Deletes an endpoint of a specified PolarDB cluster.