Skip to content

Latest commit

 

History

History
71 lines (51 loc) · 1.99 KB

README.md

File metadata and controls

71 lines (51 loc) · 1.99 KB

MLAB

MongoDB Learning, Analyzing, and Benchmarking

You might expect some blog post about MongoDB data modeling and performance on my dev.to, and discussions on Linkedin and Twitter

Example to start and use this lab

Start mongodb, prometheus, mongodb_exporter (from percona) and grafana:

docker compose down
docker compose up -d

Run some workload (insert for 5 minutes) defined in functions.js

docker compose run --rm mongosh # the entrypoint loads automatically /config/functions.js

 db.demo.drop(); 
 db.runCommand( {
   create: "demo",
   clusteredIndex: { "key": { _id: 1 }, "unique": true, "name": "demo clustered key" }
 } )

 run(30,bulkInsert, db.demo, 1, 1000);
 run(30,insertOne,db.demo);
 run(30,queryValue,db.demo);
 run(30,queryRange,db.demo);
 deleteAll(db.demo);
 db.demo.createIndex({ value: 1 });
 run(30,bulkInsert, db.demo, 1, 1000);
 run(30,replaceOne,db.demo);
 run(30,updateOne,db.demo);
 run(30,deleteOne,db.demo);
 run(30,deleteMany,db.demo);
 deleteAll(db.demo);

Run a custom workload from ten connections:

mlab(){
 for i in $(seq 1 $1)
 do
  docker compose run -T mongosh --eval "load('/config/functions.js'); run($2)" < /dev/null |
   sed -e "s/^/$i\\t/" &
 done
 wait
}

mlab 10 "300,bulkInsert,db.demo,1,1000" 

output

Run mongostat ( fields listed in mongostat.fields ):

docker compose run mongostat

mongostats

Watch grafana dashboard on port 3000 (user/password admin/admin):

image

(The first run was with a clustered index, the second one with non-clustered)