MongoDB 3 with WiredTiger: High CPU load

7.9k views Asked by At

We have 3 instances in replica. Primary with 2 cores CPU and 4 GB RAM. Secondary with 1 core CPU and 4 GB RAM. Arbiter with 1 core CPU and 2 GB RAM.

The first test:

mongodb-org-server-2.6.10-1.x86_64

logpath=/var/log/mongodb/mongod.log
logappend=true
fork=true
dbpath=/mnt/mongo
pidfilepath=/var/run/mongodb/mongod.pid

And the second test: mongodb-org-server-3.0.4-1.x86_64

processManagement:
    pidFilePath: "/var/run/mongodb/mongod.pid"
    fork: true
storage:
    dbPath: "/mnt/mongo/"
    engine: "wiredTiger"
    wiredTiger:
        collectionConfig: 
            blockCompressor: none
        engineConfig: 
            cacheSizeGB: 2
            journalCompressor: none
        indexConfig:
            prefixCompression: false
systemLog:
    destination: file
    path: "/var/log/mongodb/mongod.log"
    logAppend: true
replication:
    replSetName: testrepl

CPU usage: https://i.stack.imgur.com/E1tVc.png

With the same loadtest we have 2x CPU load on MongoDB 3 with WiredTiger engine.

MongoDB Stats: https://i.stack.imgur.com/3mLpO.png

So the question is why MongoDB 3 with WiredTiger uses 2 times more CPU? Is it normal for WiredTiger? Data in database was not changed between test. We have the same load test scenario in both times.

2

There are 2 answers

0
Marius Cotofana On

According to this thread on the MongoDB user group, the increased load is expected behaviour for the WireTiger storage engine.

4
Petr Bela On

[EDIT: The answer discusses WiredTiger in general but not specifically for this issue. See comments.]

Yes, it is normal. WiredTiger compresses the data, which costs CPU. It's recommended to provide sufficient CPU because with WiredTiger, CPU becomes the bottleneck. See some more performance tips.

In our case for example, between identical MMAPv1 (old storage engine) and WiredTiger servers, the CPU usage increased about 2x while data storage size decreased by 3x-5x. The data are also compressed in RAM so you can fit more indexes/cache into the same amount of RAM.