Tags
This will serve as a small memento of M201 MongoDB Performance.
Lesson highlights for day I
As memory operations are much stronger than I/O operations, MongoDB heavily depend on memory especially for;
- aggregation
- index traversing
- writes (first performed in memory)
- query engine
- connections (1MB for connection)
CPU power will be needed for;
- storage engine (wire tiger)
- concurrency model of use (by default all cpu cores are used)
- page compression
- data calculation
- aggregation framework
- map reduce
Recommended RAID architecture for MongoDB is Raid10.
Applications connect to MongoS which connects config servers and shards.
Applications should choose wisely;
- read concern
- write concern
- read preference
Lab setup
Here I will leash my mongo instance with vagrant and puppet. My sample configuration will be;
vagrantfile (Vagrantfile)
Vagrant.configure("2") do |config| # The most common configuration options are documented and commented below. # For a complete reference, please see the online documentation at # https://docs.vagrantup.com. # Every Vagrant development environment requires a box. config.vm.box = "debian81" # Create a private network, which allows host-only access to the machine # using a specific IP. config.vm.hostname = "mongodb" config.vm.network :private_network, ip: "192.168.10.200" # Provider-specific configuration so you can fine-tune various # backing providers for Vagrant. config.vm.provider "virtualbox" do |vb| vb.memory = 2048 vb.cpus = 1 end # Enable provisioning with a shell script. Additional provisioners such as # Puppet, Chef, Ansible, Salt, and Docker are also available. config.vm.provision :puppet do |puppet| puppet.module_path = "puppet/modules" puppet.manifests_path = "puppet/manifests" puppet.options = ['--verbose'] end config.ssh.private_key_path = ['~/.vagrant.d/insecure_private_key', '~/.ssh/id_rsa', '.vagrant\machines\default\virtualbox\private_key'] config.ssh.forward_agent = true end
puppet manifest (puppet\manifests\default.pp)
# set path for executables Exec { path => [ "/bin/", "/sbin/" , "/usr/bin/", "/usr/sbin/" ] } # list packages that should be installed $system_packages = ['vim', 'git', 'gpp', 'make',] # perform an apt-get update exec { 'update': command => 'apt-get update', require => Exec['mongodb_source_add'] } # install system packages after an update package { $system_packages: ensure => "installed", require => Exec['update'] } # Import the public key used by the package management system # sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 0C49F3730359A14518585931BC711F9BA15703C6 exec { 'mongodb_key_get': command => 'apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 0C49F3730359A14518585931BC711F9BA15703C6' } # Create a /etc/apt/sources.list.d/mongodb-enterprise.list file for MongoDB. # echo "deb http://repo.mongodb.com/apt/debian jessie/mongodb-enterprise/3.4 main" | sudo tee /etc/apt/sources.list.d/mongodb-enterprise.list exec { 'mongodb_source_add': command => 'echo "deb http://repo.mongodb.com/apt/debian jessie/mongodb-enterprise/3.4 main" | sudo tee /etc/apt/sources.list.d/mongodb-enterprise.list', require => Exec['mongodb_key_get'] } # Install the MongoDB Enterprise packages package { mongodb-enterprise: ensure => "installed", install_options => ['-y'], require => Exec['update'] }
Lab for day I
Lab requires performing a simple query on an imported json dbase. I followed the steps;
get people.json with wget
wget https://university.mongodb.com/static/MongoDB_2017_M201_February/handouts/people.a74d7de502b1.json
start mongod
Start mongod instance, and check contents of log file through tail
sudo service mongod start
Then we may perform queries on db’s as we wish