Skip to content

Commit 365b787

Browse files
authored
Merge pull request #2216 from odidev/mongo_LP
Deploy MongoDB on Google Axion C4A virtual machine
2 parents 3351f32 + f6a376d commit 365b787

File tree

8 files changed

+571
-0
lines changed

8 files changed

+571
-0
lines changed
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
---
2+
title: Deploy MongoDB on Google Axion C4A virtual machine
3+
4+
minutes_to_complete: 60
5+
6+
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.
7+
8+
learning_objectives:
9+
- Provision an Arm virtual machine on the Google Cloud Platform using the C4A Google Axion instance family, and RHEL 9 as the base image.
10+
- Install and run MongoDB on an Arm-based GCP C4A instances.
11+
- Validate the functionality of MongoDB through baseline testing.
12+
- Benchmark the MongoDB performance on Arm using Yahoo Cloud Serving Benchmark (YCSB).
13+
14+
prerequisites:
15+
- A [Google Cloud Platform (GCP)](https://cloud.google.com/free?utm_source=google&hl=en) account with billing enabled.
16+
- Basic understanding of Linux command line.
17+
- Familiarity with the [MongoDB architecture](https://www.mongodb.com/) and deployment practices on Arm64 platforms.
18+
19+
author: Jason Andrews
20+
21+
##### Tags
22+
skilllevels: Advanced
23+
subjects: Databases
24+
cloud_service_providers: Google Cloud
25+
26+
armips:
27+
- Neoverse
28+
29+
tools_software_languages:
30+
- MongoDB
31+
- YCSB
32+
33+
operatingsystems:
34+
- Linux
35+
36+
# ================================================================================
37+
# FIXED, DO NOT MODIFY
38+
# ================================================================================
39+
further_reading:
40+
- resource:
41+
title: MongoDB Manual
42+
link: https://www.mongodb.com/docs/manual/
43+
type: documentation
44+
- resource:
45+
title: MongoDB Performance Tool
46+
link: https://github.com/idealo/mongodb-performance-test#readme
47+
type: documentation
48+
- resource:
49+
title: YCSB
50+
link: https://github.com/brianfrankcooper/YCSB/wiki/
51+
type: documentation
52+
53+
54+
weight: 1 # _index.md always has weight of 1 to order correctly
55+
layout: "learningpathall" # All files under learning paths have this same wrapper
56+
learning_path_main_page: "yes" # Indicates this should be surfaced when looking for related content. Only set for _index.md of learning path content.
57+
---
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
# ================================================================================
3+
# FIXED, DO NOT MODIFY THIS FILE
4+
# ================================================================================
5+
weight: 21 # Set to always be larger than the content in this path to be at the end of the navigation.
6+
title: "Next Steps" # Always the same, html page title.
7+
layout: "learningpathall" # All files under learning paths have this same wrapper for Hugo processing.
8+
---
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
title: "About Google Axion C4A series and MongoDB"
3+
4+
weight: 2
5+
6+
layout: "learningpathall"
7+
---
8+
9+
## Google Axion C4A series
10+
11+
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.
12+
13+
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.
14+
15+
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).
16+
17+
## MongoDB
18+
MongoDB is a popular open-source NoSQL database designed for high performance, scalability, and flexibility.
19+
20+
It stores data in JSON-like BSON documents, making it ideal for modern applications that require dynamic, schema-less data structures.
21+
22+
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/).
Lines changed: 212 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,212 @@
1+
---
2+
title: Baseline Testing
3+
weight: 5
4+
5+
### FIXED, DO NOT MODIFY
6+
layout: learningpathall
7+
---
8+
9+
10+
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.
11+
12+
## MongoDB Baseline Testing (Using **mongosh**)
13+
14+
1. Connect to MongoDB
15+
16+
Open a shell session to the local MongoDB instance:
17+
```console
18+
mongosh mongodb://127.0.0.1:27017
19+
```
20+
21+
2. Create a Test Database and Collection:
22+
23+
```console
24+
use baselineDB
25+
db.createCollection("test")
26+
```
27+
This creates a new database **baselineDB** and an empty collection named test.
28+
29+
You should see an output similar to:
30+
31+
```output
32+
test> use baselineDB
33+
... db.createCollection("test")
34+
...
35+
switched to db baselineDB
36+
```
37+
3. Insert 10,000 Test Documents:
38+
39+
```javascript
40+
for (let i = 0; i < 10000; i++) {
41+
db.test.insertOne({
42+
record: i,
43+
status: "new",
44+
timestamp: new Date()
45+
})
46+
}
47+
```
48+
This simulates basic write operations with timestamped records.
49+
10,000 documents will be cretaed and inserted into the test collection of the currently selected database.
50+
The record field would increment from 0 to 9999. The status is always "new".
51+
The timestamp would capture the insertion time for each document using ***new Date()***.
52+
53+
You should see an output similar to:
54+
55+
```output
56+
{
57+
acknowledged: true,
58+
insertedId: ObjectId('6892dacfbd44e23df4750aa9')
59+
}
60+
```
61+
62+
4. Read (Query) a Subset of Documents:
63+
64+
Fetch a few documents to verify read functionality.
65+
```javascript
66+
db.test.find({ status: "new" }).limit(5)
67+
```
68+
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.
69+
70+
You should see an output similar to:
71+
72+
```output
73+
[
74+
{
75+
_id: ObjectId('6892dacbbd44e23df474e39a'),
76+
record: 0,
77+
status: 'new',
78+
timestamp: ISODate('2025-08-06T04:32:11.090Z')
79+
},
80+
{
81+
_id: ObjectId('6892dacbbd44e23df474e39b'),
82+
record: 1,
83+
status: 'new',
84+
timestamp: ISODate('2025-08-06T04:32:11.101Z')
85+
},
86+
{
87+
_id: ObjectId('6892dacbbd44e23df474e39c'),
88+
record: 2,
89+
status: 'new',
90+
timestamp: ISODate('2025-08-06T04:32:11.103Z')
91+
},
92+
{
93+
_id: ObjectId('6892dacbbd44e23df474e39d'),
94+
record: 3,
95+
status: 'new',
96+
timestamp: ISODate('2025-08-06T04:32:11.104Z')
97+
},
98+
{
99+
_id: ObjectId('6892dacbbd44e23df474e39e'),
100+
record: 4,
101+
status: 'new',
102+
timestamp: ISODate('2025-08-06T04:32:11.106Z')
103+
}
104+
]
105+
```
106+
5. Update a Document:
107+
108+
Update a specific document's field to validate update capability.
109+
```javascript
110+
db.test.updateOne({ record: 100 }, { $set: { status: "processed" } })
111+
```
112+
Above command will find the first document where record is exactly 100, and updates that document by setting its status field to "processed".
113+
114+
You should see an output similar to:
115+
116+
```output
117+
{
118+
acknowledged: true,
119+
insertedId: null,
120+
matchedCount: 1,
121+
modifiedCount: 1,
122+
upsertedCount: 0
123+
}
124+
```
125+
6. View the Updated Document Before Deletion
126+
127+
```console
128+
db.test.findOne({ record: 100 })
129+
```
130+
This retrieves the document where record is 100, allowing you to verify that its status has been updated to "processed".
131+
132+
You should see output similar to:
133+
134+
```output
135+
{
136+
_id: ObjectId('689490ddb7235c65ca74e3fe'),
137+
record: 100,
138+
status: 'processed',
139+
timestamp: ISODate('2025-08-07T11:41:17.508Z')
140+
}
141+
```
142+
143+
7. Delete a Document:
144+
145+
```javascript
146+
db.test.deleteOne({ record: 100 })
147+
```
148+
This tells MongoDB to delete one document from the test collection, where record is exactly 100.
149+
150+
You should see an output similar to:
151+
152+
```output
153+
{ acknowledged: true, deletedCount: 1 }
154+
```
155+
Now, confirm the deletion:
156+
157+
```console
158+
db.test.findOne({ record: 100 })
159+
```
160+
The above command confirms that the document was successfully deleted.
161+
162+
You should see an output similar to:
163+
```output
164+
null
165+
```
166+
167+
8. Measure Execution Time (Optional):
168+
169+
The below snippet measures how long it takes to insert documents for performance insight.
170+
```javascript
171+
var start = new Date()
172+
for (let i = 0; i < 10000; i++) {
173+
db.test.insertOne({ sample: i })
174+
}
175+
print("Insert duration (ms):", new Date() - start)
176+
```
177+
You should see an output similar to:
178+
179+
```output
180+
Insert duration (ms): 4427
181+
```
182+
9. Count Total Documents:
183+
184+
Count total entries to confirm expected data volume.
185+
```javascript
186+
db.test.countDocuments()
187+
```
188+
You should see an output similar to:
189+
190+
```output
191+
19999
192+
```
193+
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).
194+
195+
10. Clean Up (Optional):
196+
197+
Deletes the **baselineDB** database and all its contents.
198+
```javascript
199+
db.dropDatabase()
200+
```
201+
You should see an output similar to:
202+
203+
```output
204+
{ ok: 1, dropped: 'baselineDB' }
205+
```
206+
207+
The above is a destructive command that completely deletes the current database you are connected to in mongosh.
208+
209+
The above operations confirm that MongoDB is installed successfully and is functioning as expected on the GCP Arm64 environment.
210+
211+
Using **mongosh**, you validated key database operations such as **insert**, **read**, **update**, **delete**, and **count**.
212+
Now, your MongoDB instance is ready for further benchmarking and production use.

0 commit comments

Comments
 (0)