×
Community Blog Run MongoDB Workloads on PolarDB for PostgreSQL Serverless

Run MongoDB Workloads on PolarDB for PostgreSQL Serverless

This blog provides a guide to provisioning, connecting, and benchmarking a Serverless PolarDB instance with MongoDB compatibility, including its auto-scaling capabilities.

By Decai Xu, Yuanyi, Yuanyun and Suying

A new compatibility layer enables code-free migration, serverless elasticity, and PostgreSQL reliability for your document database needs.

Following the recent release of DynamoDB compatibility, we are excited to announce another major innovation for PolarDB: native compatibility with the MongoDB data model.

This new feature allows you to migrate your MongoDB-based applications to PolarDB for PostgreSQL without changing a single line of code. Gain the enterprise-grade reliability and advanced features of PostgreSQL while maintaining the flexibility and familiar development patterns of a document database.

In this post, we'll guide you through:

● Provisioning a Serverless PolarDB instance with MongoDB compatibility.

● Connecting to it using standard MongoDB tools.

● Validating its performance and auto-scaling capabilities with a benchmark test.

Key Benefits:

Seamless Migration: Preserve your existing MongoDB application code and development tools. The compatibility layer handles the translation, making migration fast and frictionless.

Effortless Scaling: Leverage the power of PolarDB Serverless to automatically scale compute resources up and down based on real-time workload demands, optimizing both performance and cost.

Unified Architecture: Combine the flexibility of MongoDB's document model with the proven reliability, ACID compliance, and rich ecosystem of PostgreSQL in a single, powerful database.

Technical Insights: How It Works

The MongoDB compatibility layer is an intelligent translation service built into PolarDB that:

● Translates the MongoDB Wire Protocol into corresponding PostgreSQL operations in real-time.

● Preserves Document Semantics by leveraging PostgreSQL's native JSONB capabilities, ensuring document-oriented data is stored and queried efficiently.

● Supports Common Operations, including most CRUD (Create, Read, Update, Delete) operations and familiar query patterns.

Getting Started: A Step-by-Step Guide

Step 1: Provision Your PolarDB Serverless Instance

First, provision a new PolarDB for PostgreSQL serverless instance with the following recommended configurations.

Configuration Item Recommended Value
Billing Type Serverless
Database Engine PostgreSQL 16
Minimum PCUs per Node 1
Maximum PCUs per Node 16
Minimum Read-only Nodes 1
Maximum Read-only Nodes 1

You can find these options on the Alibaba Cloud purchase page.

1
2

Important Note: Preview Limitation on Scaling

The current preview version supports vertical scaling (scaling up and down) but not horizontal scaling (scaling out and in). For this reason, set Maximum Read-only Nodes to 1. Full horizontal scaling capabilities will be available in the general release.

Step 2: Enable MongoDB Compatibility (Preview Access)

As this feature is currently in preview, access must be enabled for your account.

To activate the feature, contact your Alibaba Cloud account manager, technical support engineer, or open a support ticket to request access to the MongoDB compatibility preview.

Step 3: Connect to Your Instance

Once your instance is running and the feature is enabled, follow these steps to connect:

● Create a privileged database account within your PolarDB instance.

3
4

● Configure the IP whitelist to allow connections from your client machine.

5
6

● Connect using the mongo shell or your preferred MongoDB client tool.

7

Pro Tip: Use the native mongo shell client rather than generic MongoDB clients to ensure full compatibility and avoid unnecessary complexities.

Step 4: Validate Performance with YCSB

Let's validate the seamless auto-scaling capabilities. We will use the Yahoo! Cloud Serving Benchmark (YCSB), an industry-standard framework for evaluating database performance.

Benchmark Process:

1.  Prepare Data: Load a test dataset with a document structure matching a typical production workload.

8

2.  Execute Workloads: Run standard YCSB workloads (A-F) to simulate various read/write patterns.

9
10

3.  Monitor Scaling: Throughout the test, we observed the instance's resource utilization in the PolarDB console.

11
12

Performance Highlights:

Seamless Auto-Scaling: The instance automatically scaled its CPU and memory (PCUs) in response to the increasing benchmark load.

Stable Throughput: Performance remained consistent even during scaling events, with no noticeable interruptions.

Intelligent Resource Management: After the test completed, the instance automatically scaled back down to its minimum configuration, saving costs.

Low Latency: Query latency remained within acceptable thresholds throughout the high-load test.

Monitoring the console shows PCUs scaling up during the YCSB run and scaling back down afterward, demonstrating true serverless elasticity.


Conclusion and Next Steps

PolarDB for PostgreSQL with MongoDB compatibility offers a powerful, modern solution for your document database workloads. Our benchmark tests confirm that it delivers a seamless migration path, true serverless elasticity, and the enterprise-grade reliability of PostgreSQL.

Recommendations for Your Evaluation:

● Test your specific application's query patterns to validate full compatibility.

● Monitor the scaling behavior of a serverless instance under your own peak loads.

● Plan for our general release to take advantage of full horizontal scaling and other production-ready features.

We hope this guide helps you feel confident in utilizing the impressive capabilities of serverless PolarDB.


Ready to experience the future of document databases? Contact us today to request access to the preview and start migrating your MongoDB applications to a more powerful, flexible, and cost-effective platform. (Your PolarDB Serverless 50% promotion awaits!)

13

0 2 0
Share on

ApsaraDB

559 posts | 178 followers

You may also like

Comments

ApsaraDB

559 posts | 178 followers

Related Products

  • PolarDB for PostgreSQL

    Alibaba Cloud PolarDB for PostgreSQL is an in-house relational database service 100% compatible with PostgreSQL and highly compatible with the Oracle syntax.

    Learn More
  • Database Migration Solution

    Migrating to fully managed cloud databases brings a host of benefits including scalability, reliability, and cost efficiency.

    Learn More
  • Oracle Database Migration Solution

    Migrate your legacy Oracle databases to Alibaba Cloud to save on long-term costs and take advantage of improved scalability, reliability, robust security, high performance, and cloud-native features.

    Learn More
  • PolarDB for Xscale

    Alibaba Cloud PolarDB for Xscale (PolarDB-X) is a cloud-native high-performance distributed database service independently developed by Alibaba Cloud.

    Learn More