diff --git a/content/learning-paths/servers-and-cloud-computing/mongodb-on-gcp/_index.md b/content/learning-paths/servers-and-cloud-computing/mongodb-on-gcp/_index.md new file mode 100644 index 0000000000..37e306524b --- /dev/null +++ b/content/learning-paths/servers-and-cloud-computing/mongodb-on-gcp/_index.md @@ -0,0 +1,57 @@ +--- +title: Deploy MongoDB on Google Axion C4A virtual machine + +minutes_to_complete: 60 + +who_is_this_for: This Learning Path is designed for software developers looking to migrate their MongoDB workloads from x86_64 to Arm-based platforms, specifically on Google Axion-based C4A virtual machines. + +learning_objectives: + - Provision an Arm virtual machine on the Google Cloud Platform using the C4A Google Axion instance family, and RHEL 9 as the base image. + - Install and run MongoDB on an Arm-based GCP C4A instances. + - Validate the functionality of MongoDB through baseline testing. + - Benchmark the MongoDB performance on Arm using Yahoo Cloud Serving Benchmark (YCSB). + +prerequisites: + - A [Google Cloud Platform (GCP)](https://cloud.google.com/free?utm_source=google&hl=en) account with billing enabled. + - Basic understanding of Linux command line. + - Familiarity with the [MongoDB architecture](https://www.mongodb.com/) and deployment practices on Arm64 platforms. + +author: Jason Andrews + +##### Tags +skilllevels: Advanced +subjects: Databases +cloud_service_providers: Google Cloud + +armips: + - Neoverse + +tools_software_languages: + - MongoDB + - YCSB + +operatingsystems: + - Linux + +# ================================================================================ +# FIXED, DO NOT MODIFY +# ================================================================================ +further_reading: + - resource: + title: MongoDB Manual + link: https://www.mongodb.com/docs/manual/ + type: documentation + - resource: + title: MongoDB Performance Tool + link: https://github.com/idealo/mongodb-performance-test#readme + type: documentation + - resource: + title: YCSB + link: https://github.com/brianfrankcooper/YCSB/wiki/ + type: documentation + + +weight: 1 # _index.md always has weight of 1 to order correctly +layout: "learningpathall" # All files under learning paths have this same wrapper +learning_path_main_page: "yes" # Indicates this should be surfaced when looking for related content. Only set for _index.md of learning path content. +--- diff --git a/content/learning-paths/servers-and-cloud-computing/mongodb-on-gcp/_next-steps.md b/content/learning-paths/servers-and-cloud-computing/mongodb-on-gcp/_next-steps.md new file mode 100644 index 0000000000..c3db0de5a2 --- /dev/null +++ b/content/learning-paths/servers-and-cloud-computing/mongodb-on-gcp/_next-steps.md @@ -0,0 +1,8 @@ +--- +# ================================================================================ +# FIXED, DO NOT MODIFY THIS FILE +# ================================================================================ +weight: 21 # Set to always be larger than the content in this path to be at the end of the navigation. +title: "Next Steps" # Always the same, html page title. +layout: "learningpathall" # All files under learning paths have this same wrapper for Hugo processing. +--- diff --git a/content/learning-paths/servers-and-cloud-computing/mongodb-on-gcp/background.md b/content/learning-paths/servers-and-cloud-computing/mongodb-on-gcp/background.md new file mode 100644 index 0000000000..99947c23e8 --- /dev/null +++ b/content/learning-paths/servers-and-cloud-computing/mongodb-on-gcp/background.md @@ -0,0 +1,22 @@ +--- +title: "About Google Axion C4A series and MongoDB" + +weight: 2 + +layout: "learningpathall" +--- + +## Google Axion C4A series + +The Google Axion C4A series is a family of Arm-based virtual machines built on Google’s custom Axion CPU, which is based on Arm Neoverse-V2 cores. Designed for high-performance and energy-efficient computing, these virtual machine offer strong performance ideal for modern cloud workloads such as CI/CD pipelines, microservices, media processing, and general-purpose applications. + +The C4A series provides a cost-effective alternative to x86 virtual machine while leveraging the scalability and performance benefits of the Arm architecture in Google Cloud. + +To learn more about Google Axion, refer to the blog [Introducing Google Axion Processors, our new Arm-based CPUs](https://cloud.google.com/blog/products/compute/introducing-googles-new-arm-based-cpu). + +## MongoDB +MongoDB is a popular open-source NoSQL database designed for high performance, scalability, and flexibility. + +It stores data in JSON-like BSON documents, making it ideal for modern applications that require dynamic, schema-less data structures. + +MongoDB is widely used for web, mobile, IoT, and real-time analytics workloads. Learn more from the [MongoDB official website](https://www.mongodb.com/) and its [official documentation](https://www.mongodb.com/docs/). diff --git a/content/learning-paths/servers-and-cloud-computing/mongodb-on-gcp/baseline-testing.md b/content/learning-paths/servers-and-cloud-computing/mongodb-on-gcp/baseline-testing.md new file mode 100644 index 0000000000..842709484f --- /dev/null +++ b/content/learning-paths/servers-and-cloud-computing/mongodb-on-gcp/baseline-testing.md @@ -0,0 +1,212 @@ +--- +title: Baseline Testing +weight: 5 + +### FIXED, DO NOT MODIFY +layout: learningpathall +--- + + +Since MongoDB is installed successfully on your GCP C4A Arm virtual machine, follow these steps to validate that the server is running and accepting local connections. + +## MongoDB Baseline Testing (Using **mongosh**) + +1. Connect to MongoDB + +Open a shell session to the local MongoDB instance: +```console +mongosh mongodb://127.0.0.1:27017 +``` + +2. Create a Test Database and Collection: + +```console +use baselineDB +db.createCollection("test") +``` +This creates a new database **baselineDB** and an empty collection named test. + +You should see an output similar to: + +```output +test> use baselineDB +... db.createCollection("test") +... +switched to db baselineDB +``` +3. Insert 10,000 Test Documents: + +```javascript +for (let i = 0; i < 10000; i++) { + db.test.insertOne({ + record: i, + status: "new", + timestamp: new Date() + }) +} +``` +This simulates basic write operations with timestamped records. +10,000 documents will be cretaed and inserted into the test collection of the currently selected database. +The record field would increment from 0 to 9999. The status is always "new". +The timestamp would capture the insertion time for each document using ***new Date()***. + +You should see an output similar to: + +```output +{ + acknowledged: true, + insertedId: ObjectId('6892dacfbd44e23df4750aa9') +} +``` + +4. Read (Query) a Subset of Documents: + +Fetch a few documents to verify read functionality. +```javascript +db.test.find({ status: "new" }).limit(5) +``` +This command is a simple read operation to verify that your data is inserted correctly. It queries the test collection in the current database, and only returns documents where the status is "new". ***limit(5)*** returns only the first 5 matching documents. + +You should see an output similar to: + +```output +[ + { + _id: ObjectId('6892dacbbd44e23df474e39a'), + record: 0, + status: 'new', + timestamp: ISODate('2025-08-06T04:32:11.090Z') + }, + { + _id: ObjectId('6892dacbbd44e23df474e39b'), + record: 1, + status: 'new', + timestamp: ISODate('2025-08-06T04:32:11.101Z') + }, + { + _id: ObjectId('6892dacbbd44e23df474e39c'), + record: 2, + status: 'new', + timestamp: ISODate('2025-08-06T04:32:11.103Z') + }, + { + _id: ObjectId('6892dacbbd44e23df474e39d'), + record: 3, + status: 'new', + timestamp: ISODate('2025-08-06T04:32:11.104Z') + }, + { + _id: ObjectId('6892dacbbd44e23df474e39e'), + record: 4, + status: 'new', + timestamp: ISODate('2025-08-06T04:32:11.106Z') + } +] +``` +5. Update a Document: + +Update a specific document's field to validate update capability. +```javascript +db.test.updateOne({ record: 100 }, { $set: { status: "processed" } }) +``` +Above command will find the first document where record is exactly 100, and updates that document by setting its status field to "processed". + +You should see an output similar to: + +```output +{ + acknowledged: true, + insertedId: null, + matchedCount: 1, + modifiedCount: 1, + upsertedCount: 0 +} +``` +6. View the Updated Document Before Deletion + +```console +db.test.findOne({ record: 100 }) +``` +This retrieves the document where record is 100, allowing you to verify that its status has been updated to "processed". + +You should see output similar to: + +```output +{ + _id: ObjectId('689490ddb7235c65ca74e3fe'), + record: 100, + status: 'processed', + timestamp: ISODate('2025-08-07T11:41:17.508Z') +} +``` + +7. Delete a Document: + +```javascript +db.test.deleteOne({ record: 100 }) +``` +This tells MongoDB to delete one document from the test collection, where record is exactly 100. + +You should see an output similar to: + +```output +{ acknowledged: true, deletedCount: 1 } +``` +Now, confirm the deletion: + +```console +db.test.findOne({ record: 100 }) +``` +The above command confirms that the document was successfully deleted. + +You should see an output similar to: +```output +null +``` + +8. Measure Execution Time (Optional): + +The below snippet measures how long it takes to insert documents for performance insight. +```javascript +var start = new Date() +for (let i = 0; i < 10000; i++) { + db.test.insertOne({ sample: i }) +} +print("Insert duration (ms):", new Date() - start) +``` +You should see an output similar to: + +```output +Insert duration (ms): 4427 +``` +9. Count Total Documents: + +Count total entries to confirm expected data volume. +```javascript +db.test.countDocuments() +``` +You should see an output similar to: + +```output +19999 +``` +The count **19999** reflects the total documents after inserting 10,000 initial records, adding 10,000 more (in point 8), and deleting one (record: 100). + +10. Clean Up (Optional): + +Deletes the **baselineDB** database and all its contents. +```javascript +db.dropDatabase() +``` +You should see an output similar to: + +```output +{ ok: 1, dropped: 'baselineDB' } +``` + +The above is a destructive command that completely deletes the current database you are connected to in mongosh. + +The above operations confirm that MongoDB is installed successfully and is functioning as expected on the GCP Arm64 environment. + +Using **mongosh**, you validated key database operations such as **insert**, **read**, **update**, **delete**, and **count**. +Now, your MongoDB instance is ready for further benchmarking and production use. diff --git a/content/learning-paths/servers-and-cloud-computing/mongodb-on-gcp/benchmarking.md b/content/learning-paths/servers-and-cloud-computing/mongodb-on-gcp/benchmarking.md new file mode 100644 index 0000000000..2ddf4990c6 --- /dev/null +++ b/content/learning-paths/servers-and-cloud-computing/mongodb-on-gcp/benchmarking.md @@ -0,0 +1,124 @@ +--- +title: MongoDB Benchmarking +weight: 6 + +### FIXED, DO NOT MODIFY +layout: learningpathall +--- + +## MongoDB Benchmarking with YCSB (Yahoo! Cloud Serving Benchmark) + +**YCSB (Yahoo! Cloud Serving Benchmark)** is an open-source benchmarking tool for evaluating the performance of NoSQL databases under different workloads. It supports operations like read, write, update, and scan to simulate real-world usage patterns. + +### Install YCSB (Build from Source) + +```console +sudo dnf install -y git maven java-11-openjdk-devel +git clone https://github.com/brianfrankcooper/YCSB.git +cd YCSB +mvn -pl site.ycsb:mongodb-binding -am clean package +``` + +### Load Phase – Insert Initial Dataset + +This phase inserts documents into MongoDB to simulate a typical workload. + +```console +./bin/ycsb load mongodb -s \ + -P workloads/workloada \ + -p mongodb.url=mongodb://127.0.0.1:27017/ycsb +``` +The core purpose of this phase is to prepare the database with initial records (default: 1,000) for benchmarking. + +### Execute Benchmark Workload + +This phase performs actual read/write operations and reports performance metrics. +```console +./bin/ycsb run mongodb -s \ + -P workloads/workloada \ + -p mongodb.url=mongodb://127.0.0.1:27017/ycsb +``` +Workload A (from workloads/workloada) simulates a balanced read/write workload: + +- 50% reads +- 50% updates/writes + +This is designed to mimic many real-world systems where reads and writes are equally important (e.g., session stores, shopping carts, etc.). +The above command measures latency and throughput of mixed read/write operations. + + +You should see an output similar to: + +```output +Loading workload... +Starting test. +2025-08-06 06:05:50:378 0 sec: 0 operations; est completion in 0 second +mongo client connection created with mongodb://127.0.0.1:27017/ycsb +DBWrapper: report latency for each error is false and specific error codes to track for latency are: [] +2025-08-06 06:05:50:874 0 sec: 1000 operations; 1953.12 current ops/sec; [READ: Count=534, Max=8279, Min=156, Avg=312.96, 50=261, 90=436, 99=758, 99.9=8279, 99.99=8279] [CLEANUP: Count=1, Max=4139, Min=4136, Avg=4138, 50=4139, 90=4139, 99=4139, 99.9=4139, 99.99=4139] [UPDATE: Count=466, Max=26543, Min=186, Avg=384.45, 50=296, 90=444, 99=821, 99.9=26543, 99.99=26543] +[OVERALL], RunTime(ms), 512 +[OVERALL], Throughput(ops/sec), 1953.125 +[TOTAL_GCS_G1_Young_Generation], Count, 2 +[TOTAL_GC_TIME_G1_Young_Generation], Time(ms), 3 +[TOTAL_GC_TIME_%_G1_Young_Generation], Time(%), 0.5859375 +[TOTAL_GCS_G1_Old_Generation], Count, 0 +[TOTAL_GC_TIME_G1_Old_Generation], Time(ms), 0 +[TOTAL_GC_TIME_%_G1_Old_Generation], Time(%), 0.0 +[TOTAL_GCs], Count, 2 +[TOTAL_GC_TIME], Time(ms), 3 +[TOTAL_GC_TIME_%], Time(%), 0.5859375 +[READ], Operations, 534 +[READ], AverageLatency(us), 312.96067415730334 +[READ], MinLatency(us), 156 +[READ], MaxLatency(us), 8279 +[READ], 50thPercentileLatency(us), 261 +[READ], 95thPercentileLatency(us), 524 +[READ], 99thPercentileLatency(us), 758 +[READ], Return=OK, 534 +[CLEANUP], Operations, 1 +[CLEANUP], AverageLatency(us), 4138.0 +[CLEANUP], MinLatency(us), 4136 +[CLEANUP], MaxLatency(us), 4139 +[CLEANUP], 50thPercentileLatency(us), 4139 +[CLEANUP], 95thPercentileLatency(us), 4139 +[CLEANUP], 99thPercentileLatency(us), 4139 +[UPDATE], Operations, 466 +[UPDATE], AverageLatency(us), 384.4527896995708 +[UPDATE], MinLatency(us), 186 +[UPDATE], MaxLatency(us), 26543 +[UPDATE], 50thPercentileLatency(us), 296 +[UPDATE], 95thPercentileLatency(us), 498 +[UPDATE], 99thPercentileLatency(us), 821 +[UPDATE], Return=OK, 466 +``` + +### YCSB Operations & Latency Metrics + +- **Operations Count**: Total number of operations performed by YCSB for each type. +- **Average Latency (us**): The average time (in microseconds) it took to complete each operation type. +- **Min Latency (us)**: The fastest (minimum) time observed for any single operation of that type. +- **Max Latency (us)**: The slowest (maximum) time recorded for any single operation of that type. + +### Benchmark summary on x86_64: +The following benchmark results are collected on a c3-standard-4 (4 vCPU, 2 core, 16 GB Memory) x86_64 environment, running RHEL 9. + +| Operation | Count | Avg Latency (us) | Min Latency (us) | Max Latency (us) | 50th Percentile (us) | 95th Percentile (us) | 99th Percentile (us) | +|-----------|-------|------------------|------------------|------------------|-----------------------|----------------------|-----------------------| +| READ | 472 | 672.27 | 177 | 56703 | 514 | 903 | 1331 | +| UPDATE | 528 | 621.27 | 214 | 12855 | 554 | 971 | 1224 | +| CLEANUP | 1 | 4702 | 4700 | 4703 | 4703 | 4703 | 4703 | + +### Benchmark summary on Arm64: +The following benchmark results are collected on a c4a-standard-4 (4 vCPU, 16 GB Memory) Arm64 environment, running RHEL 9. + +| Operation | Count | Avg Latency (us) | Min Latency (us) | Max Latency (us) | 50th Percentile (us) | 95th Percentile (us) | 99th Percentile (us) | +|----------|------------------|------------------|------------------|------------------|----------------------|----------------------|----------------------| +| READ | 534 | 312.96 | 156 | 8279 | 261 | 524 | 758 | +| UPDATE | 466 | 384.45 | 186 | 26543 | 296 | 498 | 821 | +| CLEANUP | 1 | 4138 | 4136 | 4139 | 4139 | 4139 | 4139 | + +### **Highlights from GCP C4A Arm virtual machine** + +- Arm results show low **average latencies**, **READ** at **313 us** and **UPDATE** at **384 us**. +- **50th** to **99th percentile** latencies remain stable, indicating consistent performance. +- **Max latency** spikes (**8279 us READ**, **26543 us UPDAT**E) suggest rare outliers. diff --git a/content/learning-paths/servers-and-cloud-computing/mongodb-on-gcp/create-instance.md b/content/learning-paths/servers-and-cloud-computing/mongodb-on-gcp/create-instance.md new file mode 100644 index 0000000000..3ca28709da --- /dev/null +++ b/content/learning-paths/servers-and-cloud-computing/mongodb-on-gcp/create-instance.md @@ -0,0 +1,29 @@ +--- +title: Create Google Axion C4A Arm virtual machine +weight: 3 + +### FIXED, DO NOT MODIFY +layout: learningpathall +--- + +## Introduction + +This guide walks you through provisioning **Google Axion C4A Arm virtual machine** on GCP with the **c4a-standard-4 (4 vCPUs, 16 GB Memory)** machine type, using the **Google Cloud Console**. + +If you are new to Google Cloud, it is recommended to follow the [GCP Quickstart Guide to Create a virtual machine](https://cloud.google.com/compute/docs/instances/create-start-instance). + +For more details, kindly follow the Learning Path on [Getting Started with Google Cloud Platform](https://learn.arm.com/learning-paths/servers-and-cloud-computing/csp/google/). + +### Create an Arm-based Virtual Machine (C4A) + +To create a virtual machine based on the C4A Arm architecture: +1. Navigate to the [Google Cloud Console](https://console.cloud.google.com/). +2. Go to **Compute Engine > VM Instances** and click on **Create Instance**. +3. Under the **Machine Configuration**: + - Fill in basic details like **Instance Name**, **Region**, and **Zone**. + - Choose the **Series** as `C4A`. + - Select a machine type such as `c4a-standard-4`. +![Instance Screenshot](./image1.png) +4. Under the **OS and Storage**, click on **Change**, and select Arm64 based OS Image of your choice. For this Learning Path, we pick **Red Hat Enterprise Linux** as the Operating System with **Red Hat Enterprise Linux 9** as the Version. Make sure you pick the version of image for Arm. +5. Under **Networking**, enable **Allow HTTP traffic** to allow HTTP communications. +6. Click on **Create**, and the instance will launch. diff --git a/content/learning-paths/servers-and-cloud-computing/mongodb-on-gcp/image1.png b/content/learning-paths/servers-and-cloud-computing/mongodb-on-gcp/image1.png new file mode 100644 index 0000000000..2a65bdcde8 Binary files /dev/null and b/content/learning-paths/servers-and-cloud-computing/mongodb-on-gcp/image1.png differ diff --git a/content/learning-paths/servers-and-cloud-computing/mongodb-on-gcp/mongodb-deploy.md b/content/learning-paths/servers-and-cloud-computing/mongodb-on-gcp/mongodb-deploy.md new file mode 100644 index 0000000000..0725049259 --- /dev/null +++ b/content/learning-paths/servers-and-cloud-computing/mongodb-on-gcp/mongodb-deploy.md @@ -0,0 +1,119 @@ +--- +title: Install MongoDB on Google Axion C4A virtual machine +weight: 4 + +### FIXED, DO NOT MODIFY +layout: learningpathall +--- + + +## Install MongoDB and mongosh on Google Axion C4A virtual machine + +Install MongoDB and mongosh on GCP RHEL 9 Arm64 by downloading the binaries, setting up environment paths, configuring data and log directories, and starting the server for local access and verification. + +1. Install System Dependencies + +Install required system packages to support MongoDB: +```console +sudo dnf install -y libcurl openssl tar wget curl +``` + +2. Download annd Extract MongoDB + +Fetch and unpack the MongoDB binaries for Arm64: +```console +wget https://fastdl.mongodb.org/linux/mongodb-linux-aarch64-rhel93-8.0.12.tgz +tar -xzf mongodb-linux-aarch64-rhel93-8.0.12.tgz +ls mongodb-linux-aarch64-rhel93-8.0.12/bin +``` + +3. Add MongoDB to System PATH + +Enable running mongod from any terminal session: +```console +echo 'export PATH=~/mongodb-linux-aarch64-rhel93-8.0.12/bin:$PATH' >> ~/.bashrc +source ~/.bashrc +``` + +4. Create a data Directory + +Set up the database data directory: +```console +mkdir -p ~/mongodb-data/db +``` + +5. Start MongoDB Server + +Start MongoDB in the **foreground** (without --fork) to view real-time output and ensure it starts correctly: +```console +~/mongodb-linux-aarch64-rhel93-8.0.12/bin/mongod --dbpath ~/mongodb-data/db +``` +Once confirmed it's working, you can start MongoDB in the **background** with logging: +```console +./mongodb-linux-aarch64-rhel93-8.0.12/bin/mongod --dbpath ~/mongodb-data/db --logpath ~/mongodb-data/mongod.log --fork +``` +{{% notice Note %}}Make sure the **~/mongodb-data/db** directory exists before starting.{{% /notice %}} + +6. Install mongosh + +**mongosh** is the MongoDB Shell used to interact with your MongoDB server. It provides a modern, user-friendly CLI for running queries and database operations. + +Download and install MongoDB’s command-line shell for Arm: +```console +wget https://github.com/mongodb-js/mongosh/releases/download/v2.5.6/mongodb-mongosh-2.5.6.aarch64.rpm +sudo dnf install -y ./mongodb-mongosh-2.5.6.aarch64.rpm +``` +### Verify Mongodb and mongosh Installation + +Check if MongoDb and mongosh is properly installed: +```console +mongod --version +mongosh --version +``` +You should see an output similar to: +```output +db version v8.0.12 +Build Info: { + "version": "8.0.12", + "gitVersion": "b60fc6875b5fb4b63cc0dbbd8dda0d6d6277921a", + "openSSLVersion": "OpenSSL 3.2.2 4 Jun 2024", + "modules": [], + "allocator": "tcmalloc-google", + "environment": { + "distmod": "rhel93", + "distarch": "aarch64", + "target_arch": "aarch64" + } +} +$ mongosh --version +2.5.6 +``` + +### Connect to MongoDB via mongosh + +Start interacting with MongoDB through its shell interface: +```console +mongosh mongodb://127.0.0.1:27017 +``` +You should see an output similar to: +```output +Current Mongosh Log ID: 6891ebb158db5b705d74e399 +Connecting to: mongodb://127.0.0.1:27017/?directConnection=true&serverSelectionTimeoutMS=2000&appName=mongosh+2.5.6 +Using MongoDB: 8.0.12 +Using Mongosh: 2.5.6 + +For mongosh info see: https://www.mongodb.com/docs/mongodb-shell/ + +------ + The server generated these startup warnings when booting + 2025-08-05T07:17:45.864+00:00: Access control is not enabled for the database. Read and write access to data and configuration is unrestricted + 2025-08-05T07:17:45.864+00:00: Soft rlimits for open file descriptors too low + 2025-08-05T07:17:45.864+00:00: For customers running the current memory allocator, we suggest changing the contents of the following sysfsFile + 2025-08-05T07:17:45.864+00:00: We suggest setting the contents of sysfsFile to 0. + 2025-08-05T07:17:45.864+00:00: Your system has glibc support for rseq built in, which is not yet supported by tcmalloc-google and has critical performance implications. Please set the environment variable GLIBC_TUNABLES=glibc.pthread.rseq=0 +------ + +test> +``` + +MongoDB installation is complete. You can now proceed with the baseline testing.