To connect to a PolarDB cluster, you must provide an endpoint of the cluster. PolarDB supports cluster endpoints and primary endpoints. For each type of endpoint, you can apply for a Virtual Private Cloud (VPC)-facing endpoint to connect to the cluster over an internal network. You can also apply for a public-facing endpoint to connect to the cluster over the Internet. This topic describes how to view or apply for an endpoint in the PolarDB console.

Cluster endpoint and primary endpoint

Endpoints
Type Description Supported network type
Cluster endpoint (recommended)
  • An application can connect to multiple nodes by connecting to only one cluster endpoint.
  • This type of endpoint supports read/write splitting. Write requests are forwarded to the primary node. Read requests are forwarded to the primary node or read-only node based on the load on each node.
Note PolarDB provides a default cluster endpoint. You can create one or more custom cluster endpoints to fit your needs. When you create a custom cluster endpoint, you can specify the nodes to connect to through the endpoint and set the read/write mode. For more information, see Modify and delete a cluster endpoint.
  • Internal network
  • Internet
Primary endpoint
  • A primary endpoint allows you to connect to the primary node of the cluster. It can be used for read and write operations.
  • When the primary node fails, the primary endpoint is resolved to the new primary node.

VPC-facing endpoints and public-facing endpoints

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

Example:

  • Your Elastic Compute Service (ECS) instance can connect to your PolarDB cluster through a VPC-facing endpoint if they run in the same VPC network.
  • You can connect to your PolarDB cluster over the VPC network 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 Modify or delete an endpoint.
  • The public-facing endpoint enables connections over the Internet. A PolarDB cluster cannot achieve optimal performance when the cluster is accessed through the public-facing endpoint.
Example: You can connect to your PolarDB cluster through a public-facing endpoint to maintain databases.

View the endpoint and port

  1. Log on to the PolarDB console.
  2. On the top of the page, select the region where the target cluster is located.
  3. Find the target cluster and click the cluster ID.
  4. The Overview page is displayed. In the Endpoints section, click Switch Views in the upper-right corner of the section to switch views.
    E
    Note
    • If you use a domain name to connect to a database, you can bind the private domain name to an internal endpoint. This allows you to retain the original database domain name after the database is migrated to the cloud. Only VPC-facing endpoints can be bound to the private domain name. For more information, see Private domain names.
    • By default, a PolarDB for MySQL cluster includes port 3306 in its endpoint. You can modify the port. For more information, see Modify or delete an endpoint.

Apply for an endpoint

  1. Log on to the PolarDB console.
  2. On the top of the page, select the region where the target cluster is deployed.
  3. Find the target cluster and click the cluster ID.
  4. The Overview page is displayed. In the Endpoints section, click Switch Views in the upper-right corner of the section to switch views.
  5. Click Apply next to the required endpoint type.
    E
    Note Only public-facing endpoints can be deleted. After you create a cluster, a default VPC-facing endpoint is generated. You do not need to apply for this endpoint.
  6. In the Apply for Endpoint dialog box that appears, specify a prefix for the required endpoint and click OK.
    Note The prefix of the endpoint must meet the following conditions:
    • The prefix must be 6 to 30 characters in length, and can contain lowercase letters, digits, and hyphens (-).
    • The prefix must start with a letter and end with a digit or letter.

What to do next

Connect to a database cluster

FAQ

Q: If my application uses a public-facing endpoint to connect to a PolarDB instance, will data usage fees be incurred?

A: Alibaba Cloud does not charge for the data usage during connections to PolarDB through a public-facing endpoint.

Related operations

Operation Description
DescribeDBClusterEndpoints Queries the endpoint information of a specified PolarDB cluster.
CreateDBEndpointAddress Creates public-facing endpoints for a specified PolarDB cluster.
ModifyDBEndpointAddress Modifies the default cluster endpoint, custom cluster endpoint, primary endpoint, or private domain of a specified PolarDB cluster.
DeleteDBEndpointAddress Deletes an endpoint of a specified PolarDB cluster.