Now that MongoDB is installed on your Google Axion C4A Arm VM, verify that the server is running and accepting local connections.
Use mongosh to create a test database, run basic CRUD operations, and capture a quick insert-time baseline before you start benchmarking.
Open a shell session to the local MongoDB instance:
mongosh mongodb://127.0.0.1:27017
Switch to a new database and create a collection:
use baselineDB
db.createCollection("test")
This creates a new database named baselineDB
and an empty collection called test
.
Expected output:
switched to db baselineDB
{ ok: 1 }
Populate the collection with 10,000 timestamped documents:
for (let i = 0; i < 10000; i++) {
db.test.insertOne({
record: i,
status: "new",
timestamp: new Date()
})
}
Each document contains:
record
: a counter from 0 to 9999status
: "new"
timestamp
: the current date/time of insertionSample output:
{ acknowledged: true, insertedId: ObjectId('...') }
Verify read functionality by querying the first few documents:
db.test.find({ status: "new" }).limit(5)
This returns the first 5 documents where status
is "new"
.
Update a specific document by changing its status:
db.test.updateOne({ record: 100 }, { $set: { status: "processed" } })
This finds the document where record
is 100 and updates the status
.
Expected output:
{
acknowledged: true,
matchedCount: 1,
modifiedCount: 1
}
Confirm that the document was updated:
db.test.findOne({ record: 100 })
Expected output:
{
_id: ObjectId('...'),
record: 100,
status: 'processed',
timestamp: ISODate('...')
}
The command below tells MongoDB to delete one document from the test collection, where record is exactly 100:
db.test.deleteOne({ record: 100 })
Verify deletion:
db.test.findOne({ record: 100 })
Expected output:
null
Measure how long it takes to insert 10,000 documents:
var start = new Date()
for (let i = 0; i < 10000; i++) {
db.test.insertOne({ sample: i })
}
print("Insert duration (ms):", new Date() - start)
Sample output:
Insert duration (ms): 4427
Check the total number of documents in the collection:
db.test.countDocuments()
Expected 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).
For the sake of resetting the environment, this following command deletes the current database you are connected to in mongosh.
Drop the baselineDB
database to remove all test data:
db.dropDatabase()
Expected output:
{ ok: 1, dropped: 'baselineDB' }
These baseline operations confirm that MongoDB is functioning properly on your GCP Arm64 environment. Using mongosh
, you validated inserts, queries, updates, deletes, and basic performance timing. Your instance is now ready for benchmarking or application integration.