FAQ
This topic answers frequently asked questions about the PolarDB for MySQL document database (compatible with the MongoDB protocol) capability.
What business use cases is this capability suitable for?
This capability suits online businesses that need a flexible schema and are developed with the document model. Examples include content management, user profiling, the Internet of Things (IoT), and game save data. It is built on PolarDB for MySQL, so you can read and write the same data as documents and run complex queries and analysis through standard SQL. This makes the capability a good fit for unified data platform use cases that connect business operations and analytics with one copy of data that supports two access methods.
How is this capability billed?
The document database (compatible with the MongoDB protocol) capability itself incurs no additional charges. You pay only for the underlying PolarDB for MySQL cluster resources, such as compute node specifications, storage, and data backups. If you enable the Serverless elasticity feature on a cluster with defined specifications, billing is based on PolarDB Capacity Units (PCUs).
How do I get started?
Confirm whether your cluster meets the following requirements:
Kernel version: MySQL 8.0.2, and the minor kernel version must be 8.0.2.2.36 or later.
PolarProxy version: 2.9.22 or later.
Other limits: Serverless clusters do not currently support the document database compatibility feature.
After your cluster meets these requirements, log on to the PolarDB console and go to the target cluster's Basic Information page.
Find the Document Database Compatibility setting, and then click Enable. The system automatically creates a default Endpoint for Document Database.
Create a privileged account for the document database, and then use a MongoDB driver or
mongoshto connect. For instructions, see Use document databases (MongoDB-compatible).
Does this capability provide high availability?
Yes. Compute nodes use a high availability architecture with one primary node and multiple read-only nodes. Enterprise Edition supports up to 15 read-only nodes, and Standard Edition supports up to 7 read-only nodes. The primary node handles write requests, and the read-only nodes handle read requests. The architecture supports automatic failover. Availability is guaranteed by the underlying PolarDB for MySQL cluster.
Which cluster types do not support this capability?
The following cluster types do not support the document database (compatible with the MongoDB protocol) capability:
Serverless clusters.
NoteYou can enable the Serverless elasticity feature on a cluster with defined specifications. However, if you purchase a Serverless cluster, you cannot enable the document database (compatible with the MongoDB protocol) feature.
How do clients connect to the document database (compatible with the MongoDB protocol) endpoint?
Use a standard MongoDB driver or mongosh to connect to the document database (compatible with the MongoDB protocol) endpoint. The connection string uses the following format:
mongodb://<username>:<password>@<polardb_endpoint>:<port><username>: The document database account name, such asdoc_rootor a standard account created by usingcreateUser.<password>: The account password. URL-encode the password if it contains special characters.<polardb_endpoint>: The domain name of the document database compatibility endpoint.<port>: The port number of the document database compatibility endpoint.
Which drivers and clients are supported?
This capability supports common drivers and tools that use the standard MongoDB Wire Protocol, including mongosh, Python (pymongo), Node.js (mongoose), and the official MongoDB driver for Go. For details, see Drivers and ecosystem tools.
How does the connection layer handle read/write splitting and load balancing?
Protocol conversion happens at the database proxy layer and is decoupled from the database kernel. This lets the capability reuse the connection pooling, load balancing, and read/write splitting capabilities of PolarDB. Write requests are routed to the primary node, and read requests are distributed to read-only nodes. This delivers horizontal read scaling while maintaining protocol compatibility.
Which MongoDB protocols and features are supported?
PolarDB for MySQL is compatible with the MongoDB Wire Protocol through the database proxy layer. It supports common query, update, and projection operators, aggregation pipelines, and common database commands. For the complete list of supported operators and commands, see Compatibility and limits.
Can I migrate an existing MongoDB database to PolarDB?
Yes. Use Alibaba Cloud Data Transmission Service (DTS) to migrate your database. DTS supports schema migration, full data migration, and incremental data migration. For instructions, see Data migration guide.
What behavioral differences should I be aware of after migration?
A few administrative commands, server-side extensions, and edge-case semantics may differ from native MongoDB. Before you switch over, validate the functionality in a test environment with real workloads. Then see Compatibility and limits to confirm that the operators and commands you use are supported.
Does PolarDB support case-sensitive table names?
If your database or collection names contain uppercase letters, when you purchase a PolarDB cluster, select Case-sensitive (the default on the purchase page is Not Case-sensitive). You cannot change this setting after the cluster is created, so choose carefully.
How do I scale performance?
Vertical scaling: Upgrade the compute node specifications.
Horizontal read scaling: Add read-only nodes (up to 15 in Enterprise Edition). Read/write splitting at the database proxy layer shares the read load.
Storage scaling: Based on the cloud-native distributed storage architecture, storage capacity can scale to the PB level.
Elastic scaling: Enable the Serverless elasticity feature on a cluster with defined specifications to scale in and out within seconds based on PCUs.
Sharding is not supported. You can add read-only nodes to improve read request performance, or use vertical scaling to improve write request performance.
How do I monitor and troubleshoot performance issues?
Use the monitoring metrics, slow query logs, and SQL Explorer tools in the PolarDB console to locate slow requests. Document operations are ultimately converted into SQL statements for execution. You can therefore use the existing PolarDB for MySQL performance diagnostics capabilities, such as execution plans and SQL statistics, for analysis.