Recently, MongoDB announced their newest version – MongoDB 3.0 (3.0.1 to be very specific). What is the biggest difference compared to the earlier versions and what do you need to know to make full advantage of upgrading? Let’s dive right in.
In MongoDB 3.0 there are many innovations but in this article I just want to focus on one of them that is of great importance, if you are running your xDB on large scale – the new storage engine WiredTiger. Starting from version 3.0, MongoDB ships with the option to select between two storage engines – MMAPv1 and WiredTiger. MMAPv1 has been the storage engine that powered MongoDB since the very beginning and till now it was the only option to go with. Now you can select what storage engine you would like to use. A thing to remember – as default the original MMAPv1 engine is installed. So, why would you want to go for WiredTiger? Simply for two reasons:
- Performance – because of the way, how WiredTiger writes files to disk, there is a gain of performance over the MMAPv1. Multiple-level caching also helps when flushing data from memory to disk (compared to the MMAPv1 which basically relies on the underlying operating system to handle data persistence to disk.
- Compression – There is no compression on MMAPv1 whereas there are two levels of compression available in WiredTiger. By default the snappy compression method is active, but you can activate a more space-saving and CPU-intensive zlib compression method. Of course all compression can be also de-activated.
What changes does WiredTiger require on xDB?
Fortunately zero. The storage engine takes care of saving the content from the database and does not have impact on the way how the application communicates with the database. Therefore it is just matter of activating it. If you are running an existing xDB installation and you would like to switch to WiredTiger, there is a migration procedure to perform.
UPDATE 14.4.2015: Although xDB requires no change, due to updates in the security model of MongoDB 3.0 (regardless of WiredTiger), you might need to update the C# Mongo drivers in Sitecore. To date Sitecore 8 Update 2 contains the driver version 22.214.171.124, which is not entirely compatible with MongoDB 3.0. Thanks to the guys in the comments, especially Richard, for pointing this out.
Any automation at hand for sandbox environments?
Of course! If you are installig a Sitecore sandbox environment and want to use MongoDB 3.0 with WiredTiger, here you go with a PowerShell configuration script that will set up the MongoDB Windows service, running WiredTiger:
# Setup of folders and file names for the MongoDB installation
$mongoPath = "C:\Program Files\MongoDB\Server\3.0"
$mongoDbConfigPath = "$mongoPath\mongod.cfg"
$dbPath = "C:\MongoData"
& $mongoPath\bin\mongod.exe --config $mongoDbConfigPath --install --storageEngine wiredTiger
& net start mongodb