Skip to content

Commit 6c27700

Browse files
Merge pull request #1848 from kielfriedt/main
added more details on 3 nodes replica set
2 parents 0006246 + 215bad3 commit 6c27700

File tree

6 files changed

+142
-168
lines changed

6 files changed

+142
-168
lines changed

content/learning-paths/servers-and-cloud-computing/mongodb/benchmark_mongodb-8.0.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ sudo yum install python2
2828
{{< /tab >}}
2929
{{< /tabpane >}}
3030

31-
For Ubuntu 22.04 and 24.04, Python 2 is not available using the package manager.
31+
For Ubuntu 22.04 and 24.04, Python 2 is not available using the package manager.
3232

3333
You can install Python 2.7 using:
3434

@@ -61,16 +61,16 @@ cd ycsb-0.17.0
6161
./bin/ycsb
6262
```
6363

64-
## Load/Insert Test on MongoDB
64+
## A simple Load/Insert Test on MongoDB
6565

66-
To load and test the performance of loading data(INSERT) into default database `ycsb` at `localhost:27017` where MongoDB is running using the synchronous driver run the following command:
66+
To load and test the performance of loading data(INSERT) into default database `ycsb` at `(localhost/Primary Node):27017` where MongoDB is running using the synchronous driver run the following command:
6767

6868
```console
6969
./bin/ycsb load mongodb -s -P workloads/workloada -p mongodb.url=mongodb://localhost:27017/ycsb?w=0 -threads 10
7070
```
7171
The "-P" parameter is used to load property files. In this example, you used it load the workloada parameter file which sets the recordcount to 1000 in addition to other parameters. The "-threads" parameter indicates the number of threads and is set to 1 by default.
7272

73-
## Update/Read/Read Modify Write Test on MongoDB
73+
## A simple Update/Read/Read Modify Write Test on MongoDB
7474

7575
To test the performance of executing a workload which includes running UPDATE, Read Modify Write(RMW) and/or READ operations on the data using 10 threads for example, use the following command:
7676

@@ -115,5 +115,5 @@ At the end of each test, statistics are printed to the console. Shown below is t
115115
...
116116
```
117117

118-
Continue to the next section to run YCSB on a 3 node cluster.
118+
[Continue to the next section to run YCSB on a 3 node cluster.](/learning-paths/servers-and-cloud-computing/mongodb/replica_set_testing)
119119

Lines changed: 84 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -1,81 +1,40 @@
11
---
22
# User change
3-
title: "Run YCSB using a 3 node replica set"
3+
title: "Creating MongoDB test scenarios"
44

5-
draft: true
6-
7-
weight: 5 # (intro is 1), 2 is first, 3 is second, etc.
5+
weight: 3 # (intro is 1), 2 is first, 3 is second, etc.
86

97
# Do not modify these elements
108
layout: "learningpathall"
119
---
12-
13-
The recommended MongoDB YCSB test setup is a relica set containing three nodes of equal size. The primary node is the node you send the YCSB traffic to and the others are secondary nodes.
10+
## MongoDB test scenarios
11+
To test Mongodb you need two parts. A instance running the testing software([YCSB](/learning-paths/servers-and-cloud-computing/mongodb/benchmark_mongodb-8.0)). one or more instances running MongoDB in some configuration. The recommended MongoDB test setup is a three node relica set. These three nodes are of equal size with one instance being desigated as the primary node( the target for test traffic ) and the others as secondary nodes.
1412

1513
## What is a replica set?
1614

17-
A replica set is a group of instances that maintain the same data set. A replica set contains many nodes, but 3 nodes are used for testing.
15+
A replica set is a group of instances that maintain the same dataset. A replica set contains many nodes, but three nodes are the most common for testing.
1816

1917
## What node size should I use?
2018

21-
The most common size for testing MongoDB is an 8 vCPU instance. You can test with any sized machine, but if you are looking for ideal testing conditions 8 vCPUs is enough. Each node should have 32GB of RAM.
22-
23-
You should keep the complete data set in memory. Additional details abut the recommended configuration are provided below.
24-
25-
## Create a replica set
26-
27-
Create a 3 node replica set by starting 3 Arm instances with the specifications above.
28-
29-
Install MongoDB on each node using the previously provided instructions.
30-
31-
Select 1 instance as the primary node and install YCSB on the instance.
32-
33-
## Initialize the replica set
34-
35-
1. Set variables with the IP addresses of each node:
19+
The most common size for testing MongoDB is an 8 vCPU instance. You can test with any sized instance, but if you are looking for ideal testing conditions, 8 vCPUs is enough. Each node should have atleast 32GB of RAM.
3620

37-
```bash
38-
PRIMARY_NODE_IP="<primary-node-ip>"
39-
SECONDARY_NODE1_IP="<secondary-node1-ip>"
40-
SECONDARY_NODE2_IP="<secondary-node2-ip>"
41-
```
21+
To achieve the best results, its recommended to keep the complete data set in memory. If you see disk access when running tests, increase the RAM size of your instances. Additional details about the recommended configuration are provided below.
4222

43-
2. Connect to the primary node using the MongoDB shell:
44-
45-
```bash
46-
mongosh --host <primary-node-ip>:27017
47-
```
23+
## Creating replica sets
4824

49-
3. Initialize the replica set with the following command:
25+
You can create replica sets of any size(two is the minimum). Three is recemmended but you can add as many as you like.
5026

51-
```bash
52-
PRIMARY_NODE_IP="<primary-node-ip>"
53-
SECONDARY_NODE1_IP="<secondary-node1-ip>"
54-
SECONDARY_NODE2_IP="<secondary-node2-ip>"
27+
## Three node replica sets
5528

56-
mongosh --host $PRIMARY_NODE_IP:27017 <<EOF
57-
rs.initiate({
58-
_id: "rs0",
59-
members: [
60-
{ _id: 0, host: "$PRIMARY_NODE_IP:27017" },
61-
{ _id: 1, host: "$SECONDARY_NODE1_IP:27017" },
62-
{ _id: 2, host: "$SECONDARY_NODE2_IP:27017" }
63-
]
64-
})
65-
EOF
66-
```
29+
To creating a three node replica set, start by launching three [Arm based instance](/learning-paths/servers-and-cloud-computing/csp/) of equal size.
6730

68-
3. Verify the replica set status:
31+
[install](/learning-paths/servers-and-cloud-computing/mongodb/run_mongodb) Mongodb on all three instances.
6932

70-
```bash
71-
mongosh --host $PRIMARY_NODE_IP:27017 <<EOF
72-
rs.status()
73-
EOF
74-
```
33+
Once all three instances are up and running. Modify the service and configuration file for all instances.
7534

7635
## Modify the MongoDB configuration
7736

78-
Use a text editor to edit the file `/etc/mongodb.conf` file and replace the contents of the file with the text below.
37+
Use a text editor to edit the file `/etc/mongodb.conf` and replace the contents of the file with the text below.
7938

8039
```console
8140
# Configuration Options: https://docs.mongodb.org/manual/reference/configuration-options/
@@ -111,6 +70,8 @@ setParameter:
11170
tlsWithholdClientCertificate: true
11271
```
11372

73+
**Details of what all these mean is below:**
74+
11475
**systemLog:** Contains locations and details of where logging should be contained.
11576
- **path:** Location for logging
11677

@@ -135,39 +96,87 @@ setParameter:
13596

13697
If you want to use encryption you will need to add the security and keyFile to your configuration. As well as change some of the parameters in the `mongod.conf` file.
13798

99+
Run this command to reload the new configurtion.
138100

139-
## Recommended Tests on MongoDB
140-
141-
The most common real world test to run is a 95/5 test, 95% read and 5% update. 100/0 and 90/10 are also popular.
101+
```
102+
sudo service mongod restart
103+
```
142104

143-
Run the following commands for about 5 mins before collecting data.
105+
## Modify the MongoDB service
144106

145-
Load the dataset:
107+
Use a text editor to edit the file `/etc/systemd/system/mongod.service` and replace the contents of the file with the text below.
146108

147-
```console
148-
./bin/ycsb load mongodb -s -P workloads/workloadb -p mongodb.url=mongodb://localhost:27017 -p compressibility=2 -p fieldlengthdistribution=zipfian -p minfieldlength=50 -threads 64 -p recordcount=20000000
109+
```
110+
[Unit]
111+
Description=High-performance, schema-free document-oriented database
112+
After=network.target
113+
Documentation=https://docs.mongodb.org/manual
114+
115+
[Service]
116+
User=mongodb
117+
Group=mongodb
118+
ExecStart=/usr/bin/mongod --quiet --config /etc/mongod.conf
119+
120+
# Recommended limits for for mongod as specified in
121+
# https://docs.mongodb.com/manual/reference/ulimit/#recommended-ulimit-settings
122+
# (file size)
123+
LimitFSIZE=infinity
124+
# (cpu time)
125+
LimitCPU=infinity
126+
# (virtual memory size)
127+
LimitAS=infinity
128+
# (locked-in-memory size)
129+
LimitMEMLOCK=infinity
130+
# (open files)
131+
LimitNOFILE=64000
132+
# (processes/threads)
133+
LimitNPROC=64000
134+
135+
[Install]
136+
WantedBy=multi-user.target
149137
```
150138

151-
Run the 95/5 test:
139+
details on these can be found here: https://docs.mongodb.com/manual/reference/ulimit/#recommended-ulimit-settings
152140

153-
```console
154-
./bin/ycsb run mongodb -s -P workloads/workloadb -p mongodb.url=mongodb://localhost:27017 -p minfieldlength=50 -p compressibility=2 -p maxexecutiontime=120 -threads 64 -p operationcount=40000000 -p recordcount=20000000 -p requestdistribution=zipfian -p readproportion=0.95 -p updateproportion=0.05
141+
Run this command to reload the service.
155142

143+
```
144+
sudo ystemctl daemon-reload
156145
```
157146

158-
Run the 100/0 test:
147+
**Once all three instances are created and have mongodb installed, select one to be your primary node. The remaining instances will be secondary nodes.**
159148

160-
```console
161-
./bin/ycsb run mongodb -s -P workloads/workloadc -p mongodb.url=mongodb://Localhost:27017 -p minfieldlength=50 -p compressibility=2 -p maxexecutiontime=120 -threads 64 -p operationcount=40000000 -p recordcount=20000000 -p requestdistribution=zipfian -p readproportion=1.0 -p updateproportion=0.0
162-
```
149+
## Initialize the replica set
163150

164-
Run the 90/10 test:
151+
Connect to the primary node and run the following commands below.
165152

166-
```console
167-
./bin/ycsb run mongodb -s -P workloads/workloadb -p mongodb.url=mongodb://localhost:27017 -p minfieldlength=50 -p compressibility=2 -p maxexecutiontime=120 -threads 64 -p operationcount=40000000 -p recordcount=20000000 -p requestdistribution=zipfian -p readproportion=0.90 -p updateproportion=0.10
168-
```
153+
1. Set variables with the IP addresses of each node:
154+
155+
```bash
156+
PRIMARY_NODE_IP="<primary-node-ip>"
157+
SECONDARY_NODE1_IP="<secondary-node1-ip>"
158+
SECONDARY_NODE2_IP="<secondary-node2-ip>"
159+
```
169160

170-
## Other tests
161+
2. Initialize the replica set with the following command:
162+
163+
```
164+
mongosh --host $PRIMARY_NODE_IP:27017 <<EOF
165+
rs.initiate({
166+
_id: "rs0",
167+
members: [
168+
{ _id: 0, host: "$PRIMARY_NODE_IP:27017", priority: 2, votes: 1 },
169+
{ _id: 1, host: "$SECONDARY_NODE1_IP:27017", priority: 1, votes: 1 },
170+
{ _id: 2, host: "$SECONDARY_NODE2_IP:27017", priority: 1, votes: 1 }
171+
]
172+
})
173+
EOF
174+
```
171175
172-
For instructions on running any other tests or more details on the metrics reported, refer to the [GitHub project for the YCSB.](https://github.com/brianfrankcooper/YCSB/wiki/).
176+
3. Verify the replica set status:
173177
178+
```bash
179+
mongosh --host $PRIMARY_NODE_IP:27017 <<EOF
180+
rs.status()
181+
EOF
182+
```

content/learning-paths/servers-and-cloud-computing/mongodb/mongodb_configuration.md

Lines changed: 0 additions & 84 deletions
This file was deleted.

content/learning-paths/servers-and-cloud-computing/mongodb/perf_mongodb.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
# User change
3-
title: "Measure performance of MongoDB on Arm"
4-
weight: 3 # 1 is first, 2 is second, etc.
3+
title: "Alternative performance testing of MongoDB"
4+
weight: 6 # 1 is first, 2 is second, etc.
55

66
# Do not modify these elements
77
layout: "learningpathall"
@@ -53,7 +53,7 @@ Use the following options:
5353
* `-t` defines the number of threads
5454
* `-db` defines the database to use
5555
* `-c` defines how the data is collected.
56-
56+
5757
For example:
5858
```bash { cwd="./mongodb-performance-test" }
5959
export jarfile=./latest-version/mongodb-performance-test.jar

0 commit comments

Comments
 (0)