Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,18 @@ cascade:

minutes_to_complete: 30

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 the Microsoft Azure Cobalt 100 processors.
who_is_this_for: This Learning Path is designed for software developers looking to migrate their MongoDB workloads to Arm-based platforms, specifically on the Microsoft Azure Cobalt 100 processors.

learning_objectives:
- Provision an Azure Arm64 virtual machine using Azure console, with Ubuntu Pro 24.04 LTS as the base image.
- Deploy the MongoDB on an Azure ubuntu virtual machine.
- Perform MongoDB baseline testing and benchmarking on both x86_64 and Arm64 virtual machine.
- Provision an Azure Arm64 Cobalt 100 based virtual machine using Azure console, with Ubuntu Pro 24.04 LTS as the base image.
- Deploy MongoDB on an Azure Cobalt 100 based virtual machine.
- Perform MongoDB baseline testing and benchmarking on the Arm64 virtual machine.

prerequisites:
- A [Microsoft Azure](https://azure.microsoft.com/) account with access to Cobalt 100 based instances (Dpsv6).
- Basic understanding of Linux command line.
- Familiarity with the [MongoDB architecture](https://www.mongodb.com/) and deployment practices on Arm64 platforms.

author: Jason Andrews
author: Pareena Verma

### Tags
skilllevels: Introductory
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ layout: learningpathall


### Baseline testing of MongoDB
Perform baseline testing by verifying MongoDB is running, logging into the shell, executing a few test queries, and monitoring live performance. This ensures the database is functioning correctly before starting any benchmarks.
In this section you will perform baseline testing by verifying MongoDB is running, logging into the shell, executing a few test queries, and monitoring live performance. This ensures the database is functioning correctly before starting any benchmarks.

1. Verify Installation & Service Health

Expand All @@ -17,11 +17,12 @@ ps -ef | grep mongod
mongod --version
netstat -tulnp | grep 27017
```
An explanation of what each command is doing:
- **ps -ef | grep mongod** – Checks if the MongoDB server process is running.
- **mongod --version** – Shows the version of MongoDB installed.
- **netstat -tulnp | grep 27017** – Checks if MongoDB is listening for connections on its default port 27017.

You should see an output similar to:
You should see output similar to:

```output
mongod --version
Expand All @@ -48,12 +49,12 @@ tcp 0 0 127.0.0.1:27017 0.0.0.0:* LISTEN

2. Storage and Health Check

Run the command below to check how fast your storage can **randomly read small 4KB chunks** from a 100 MB file for 30 seconds, using one job, and then show a summary report:
To perform a storage and health check, run the command below. This command checks how fast your storage can randomly read small 4KB chunks from a 100 MB file for 30 seconds, using one job, followed by a summary report:

```console
fio --name=baseline --rw=randread --bs=4k --size=100M --numjobs=1 --time_based --runtime=30 --group_reporting
```
You should see an output similar to:
You should see output similar to:

```output
baseline: (g=0): rw=randread, bs=(R) 4096B-4096B, (W) 4096B-4096B, (T) 4096B-4096B, ioengine=psync, iodepth=1
Expand Down Expand Up @@ -91,6 +92,13 @@ The output shows how fast it read data (**16.6 MB/s**) and how many reads it did

3. Connectivity and CRUD Sanity Check

To verify that the MongoDB server is reachable you will perform a connectivity check. You will run a sanity test of core database functionality and permissions, refered to as CRUD:

C - Create: Insert a new record/document into the database.
R - Read: Query the database to retrieve data.
U - Update: Modify an existing record.
D - Delete: Remove a record.

```console
mongosh --host localhost --port 27017
```
Expand All @@ -107,7 +115,7 @@ exit
```
These commands create a test record, read it, update its value, and then delete it a simple way to check if MongoDB’s basic **add, read, update, and delete** operations are working.

You should see an output similar to:
You should see output similar to:

```output
test> use baselineDB
Expand Down Expand Up @@ -141,6 +149,8 @@ baselineDB> db.testCollection.deleteOne({ name: "baseline-check" })

4. Basic Query Performance Test

You will now perform a lightweight query performance check:

```console
mongosh --eval '
db = db.getSiblingDB("baselineDB");
Expand All @@ -150,16 +160,17 @@ db.perf.find({ value: { $gt: 0.5 } }).count();
print("Query Time (ms):", new Date() - start);
'
```
The command connected to MongoDB, switched to the **baselineDB** database, inserted **1,000 documents** into the perf collection, and then measured the execution time for counting documents where **value > 0.5**. The final output displayed the **query execution time** in milliseconds.
The command connected to MongoDB, switched to the `baselineDB` database, inserted 1,000 documents into the perf collection, and then measured the execution time for counting documents where value > 0.5. The final output displayed the query execution time in milliseconds.

You should see an output similar to:
You should see the Query Time output similar to:

```output
Query Time (ms): 2
```

5. Index Creation Speed Test

You will now run a performance sanity check that measures how long MongoDB takes to create an index on a given collection:
```console
mongosh --eval '
db = db.getSiblingDB("baselineDB");
Expand All @@ -168,24 +179,26 @@ db.perf.createIndex({ value: 1 });
print("Index Creation Time (ms):", new Date() - start);
'
```
The test connected to MongoDB, switched to the **baselineDB** database, and created an index on the **value** field in the **perf** collection. The index creation process completed in **22 milliseconds**, indicating relatively fast index building for the dataset size.
The test connected to MongoDB, switched to the `baselineDB` database, and created an index on the value field in the `perf` collection. The index creation process completed in 22 milliseconds, indicating relatively fast index building for the dataset size.

You should see an output similar to:
You should see output similar to:

```output
Index Creation Time (ms): 22
```

6. Concurrency Smoke Test

You will now verify that MongoDB can handle concurrent client connections and inserts without errors:

```console
for i in {1..5}; do
mongosh --eval 'use baselineDB; db.concurrent.insertMany([...Array(1000).keys()].map(k => ({ test: k, ts: new Date() })))' &
done
wait
```
This command runs **five MongoDB insert jobs at the same time**, each adding **1,000 new records** to the **baselineDB.concurrent** collection.
It’s a quick way to test how MongoDB handles **multiple users writing data at once**.
This command runs five MongoDB insert jobs at the same time, each adding 1,000 new records to the `baselineDB.concurrent` collection.
It is a quick way to test how MongoDB handles multiple users writing data at once.

You should see an output similar to:

Expand All @@ -207,8 +220,8 @@ switched to db baselineDB;
[5]+ Done mongosh --eval 'use baselineDB; db.concurrent.insertMany([...Array(1000).keys()].map(k => ({ test: k, ts: new Date() })))'
```

**Five parallel MongoDB shell sessions** were executed, each inserting **1,000** test documents into the baselineDB.concurrent collection. All sessions completed successfully, confirming that concurrent data insertion works as expected.
Five parallel MongoDB shell sessions were executed, each inserting 1,000 test documents into the baselineDB.concurrent collection. All sessions completed successfully, confirming that concurrent data insertion works as expected.

The above operations confirm that MongoDB is installed successfully and is functioning as expected on the Azure Cobalt 100 (Arm64) environment.
With these tests you have confirmed that MongoDB is installed successfully and is functioning as expected on the Azure Cobalt 100 (Arm64) environment.

Now, your MongoDB instance is ready for further benchmarking and production use.
You are now ready to perform further benchmarking for MongoDB.
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ layout: learningpathall

## Benchmark MongoDB with **mongotop** and **mongostat**

This guide will help the user measure MongoDBs performance in real time.
The user will install the official MongoDB database tools, start MongoDB, run a script to simulate heavy load, and watch the databases live performance using **mongotop** and **mongostat**.
In this section, you will measure MongoDB's performance in real time.
You will install the official MongoDB database tools, start MongoDB and run a script to simulate heavy load. With the script running you will then meassure the database's live performance using **mongotop** and **mongostat**.

1. Install MongoDB Database Tools

Expand All @@ -20,7 +20,7 @@ sudo apt install -y ./mongodb-database-tools-ubuntu2404-arm64-100.13.0.deb
echo 'export PATH=$PATH:~/mongodb-database-tools-ubuntu2404-arm64-100.13.0/bin' >> ~/.bashrc
source ~/.bashrc
```
These commands download and unpack MongoDBs official monitoring tools (**mongotop** & **mongostat**), then add them to your PATH so you can run them from any terminal.
These commands download and unpack MongoDB's official monitoring tools (**mongotop** & **mongostat**), then add them to your PATH so you can run them from any terminal.

2. Verify the Installation

Expand All @@ -30,7 +30,7 @@ mongostat --version
```
This checks that both tools were installed correctly and are ready to use.

You should see an output similar to:
You should see output similar to:
```output
mongostat --version
mongotop version: 100.13.0
Expand All @@ -52,11 +52,11 @@ Go version: go1.23.11
```console
mongod --dbpath /var/lib/mongo --logpath /var/log/mongodb/mongod.log --fork
```
These commands create a folder for MongoDBs data, then start the database server in the background, allowing connections from any IP, and save logs for troubleshooting.
These commands create a folder for MongoDB's data, then start the database server in the background, allowing connections from any IP, and save logs for troubleshooting.

4. Create a Long-Running Load Script for Benchmarking

Save this script file as **long_system_load.js**:
Use a file editor of your choice and create a file named `long_system_load.js` with the content below:

```javascript
function randomString(len) {
Expand Down Expand Up @@ -109,15 +109,15 @@ for (let cycle = 0; cycle < totalCycles; cycle++) {
print("=== Long load generation completed ===");
```

This is the load generator script, it creates several collections and repeatedly **inserts, queries, updates** and **deletes** data. Running it simulates real application traffic so the monitors have something to measure.
This is the load generator script, it creates several collections and repeatedly inserts, queries, updates and deletes data. Running it simulates real application traffic so the monitors have something to measure.

{{% notice Note %}}
Before proceeding, the load script and the monitoring tools must be run in separate terminals simultaneously.

- The load script continuously generates activity in MongoDB, keeping the database busy with multiple operations.
- The mongotop and mongostat tools monitor and report this activity in real time as it happens.

If all commands are run in the same terminal, the monitoring tools will only start after the script finishes, preventing real-time observation of MongoDBs performance.
If all commands are run in the same terminal, the monitoring tools will only start after the script finishes, preventing real-time observation of MongoDB's performance.
{{% /notice %}}

### Run the load script (start the workload) — Terminal 1
Expand All @@ -128,7 +128,7 @@ mongosh < long_system_load.js

This command tells the MongoDB shell to execute the entire script. The script will run through its cycles and print the progress while generating the read/write activity on the server.

You should see an output similar to:
You should see output similar to:
```output
test> // long_system_load.js

Expand Down Expand Up @@ -255,7 +255,7 @@ test> print("=== Long load generation completed ===");

```

The load has been generated successfully. Now, you can proceed with the monitoring:
The load has been generated successfully. Now, you can proceed to the next section where you will monitor this running workload with:

- **mongotop** to observe activity per collection.
- **mongostat** to monitor overall operations per second, memory usage, and network activity.
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ layout: learningpathall

## Introduction

There are several ways to create an Arm-based Cobalt 100 virtual machine : the Microsoft Azure console, the Azure CLI tool, or using your choice of IaC (Infrastructure as Code). This guide will use the Azure console to create a virtual machine with Arm-based Cobalt 100 Processor.
There are several ways to create an Arm-based Cobalt 100 virtual machine : the Microsoft Azure console, the Azure CLI tool, or using your choice of IaC (Infrastructure as Code). In this section, you will use the Azure console to create a virtual machine with Arm-based Azure Cobalt 100 Processor.

This learning path focuses on the general-purpose virtual machine of the D series. Please read the guide on [Dpsv6 size series](https://learn.microsoft.com/en-us/azure/virtual-machines/sizes/general-purpose/dpsv6-series) offered by Microsoft Azure.

If you have never used the Microsoft Cloud Platform before, please review the microsoft [guide to Create a Linux virtual machine in the Azure portal](https://learn.microsoft.com/en-us/azure/virtual-machines/linux/quick-create-portal?tabs=ubuntu).
While the steps to create this instance are included here for your convenience, you can also refer to the [Deploy a Cobalt 100 Virtual Machine on Azure Learning Path](/learning-paths/servers-and-cloud-computing/cobalt/)

#### Create an Arm-based Azure Virtual Machine

Expand Down Expand Up @@ -43,8 +43,4 @@ Creating a virtual machine based on Azure Cobalt 100 is no different from creati

![Azure portal VM creation — Azure Cobalt 100 Arm64 virtual machine (D4ps_v6) alt-text#center](images/final-vm.png "Figure 5: VM deployment confirmation in Azure portal")

{{% notice Note %}}

To learn more about Arm-based virtual machine in Azure, refer to “Getting Started with Microsoft Azure” in [Get started with Arm-based cloud instances](/learning-paths/servers-and-cloud-computing/csp/azure).

{{% /notice %}}
While the virtual machine ready, proceed to the next section to delpoy MongoDB on your running instance.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ echo 'export PATH=/usr/local/mongodb/bin:$PATH' | sudo tee /etc/profile.d/mongod
source /etc/profile.d/mongodb.sh
```

4. Create a data and log directories
4. Create data and log directories to use with MongoDB:

Set up the database data directory:
```console
Expand All @@ -47,7 +47,7 @@ sudo chown -R $USER:$USER /var/lib/mongo /var/log/mongodb

5. Start MongoDB Server

Start MongoDB manually:
You can start MongoDB manually as shown:
```console
mongod --dbpath /var/lib/mongo --logpath /var/log/mongodb/mongod.log --fork
```
Expand Down Expand Up @@ -77,12 +77,12 @@ source /etc/profile.d/mongosh.sh

### Verify MongoDB and mongosh Installation

Check if MongoDB and mongosh is properly installed:
Check if MongoDB and mongosh are properly installed on your machine:
```console
mongod --version
mongosh --version
```
You should see an output similar to:
You should see output similar to:
```output
db version v8.0.12
Build Info: {
Expand All @@ -102,11 +102,11 @@ Build Info: {

### Connect to MongoDB via mongosh

Start interacting with MongoDB through its shell interface:
You can now start interacting with MongoDB through its shell interface:
```console
mongosh mongodb://127.0.0.1:27017
```
You should see an output similar to:
You should see output on your terminal similar to:
```output
Current Mongosh Log ID: 68b573411523231d81a00aa0
Connecting to: mongodb://127.0.0.1:27017/?directConnection=true&serverSelectionTimeoutMS=2000&appName=mongosh+2.3.8
Expand All @@ -130,4 +130,4 @@ For mongosh info see: https://www.mongodb.com/docs/mongodb-shell/
test>
```

MongoDB installation is complete. You can now proceed with the baseline testing.
With this you have verified that the MongoDB installation is complete. You can now proceed with the baseline testing of MongoDB on your Azure Cobalt 100 based VM.
Loading