user1932034
user1932034

Reputation: 149

MongoDB: big size of mapped memory

I use Mongo 2.4.9 and I have a replica sets for three nodes. I have performed db.serverStatus().mem and see that size of mapped is very high, 47GB:

db.serverStatus().mem
{
        "bits" : 64,
        "resident" : 266,
        "virtual" : 10149,
        "supported" : true,
        "mapped" : 47402,
        "mappedWithJournal" : 65730
}

Result of db.stats(1024)

{
        "db" : "xxxxx",
        "collections" : 7,
        "objects" : 670488,
        "avgObjSize" : 2890.6140721385023,
        "dataSize" : 1892697,
        "storageSize" : 2273304,
        "numExtents" : 49,
        "indexes" : 42,
        "indexSize" : 399378,
        "fileSize" : 10416128,
        "nsSizeMB" : 16,
        "dataFileVersion" : {
                "major" : 4,
                "minor" : 5
        },
        "ok" : 1
}

In megabytes

"dataSize" : 1848mb
"storageSize" : 2220mb
"fileSize" : 10172mb

WorkingSet info:

"workingSet" : {
         "note" : "thisIsAnEstimate",
         "pagesInMemory" : 152599,
         "computationTimeMicros" : 31143,
         "overSeconds" : 1728
 }

Size(Mb) = 152599*4kb -> convert to Mb = 596 Mb

My question is why the size of mapped memory is 4,2 times greater than fileSize and 15159 times greater than the storageSize or dataSize ? Mapped memory memory continues to grow slowly.

Note: OS: Red Hat Enterprise Linux Server release 5.7 (Tikanga) Physical memory: 3892Mb

I read this article but still don't understand why the size of mapped memory so large taking into account the enough small size of real data (filesize).

Thanks.

Upvotes: 0

Views: 1488

Answers (1)

Maksym Strukov
Maksym Strukov

Reputation: 2689

How many databases do you have on your mongo instance? The thing is serverStatus provides instance info taking into account all databases it has, regarding mapped field:

The value of mapped provides the amount of mapped memory, in megabytes (MB), by the database. Because MongoDB uses memory-mapped files, this value is likely to be to be roughly equivalent to the total size of your database or databases.

While db.stats:

Returns statistics that reflect the use state of a single database.

If there aren't any other databases on your instance take a look at the size of you local db. This could be quite big depending on your oplog size for the replica set.

ANSWER TO THE COMMENT:

Changing oplog size is not a trivial operation and it's also very important to pick a proper oplog size as it affects delayed members and replication lag. I suggest reading this article first Change the Size of the Oplog.

You don't have to worry that the size of mapped memory exceeds your physical memory and it should not be the reason of poor query performance by itself. Mapped memory is not "real" memory allocation. It's resident memory that shows how much memory mongo explicitly owns in RAM.

The portion of oplog in the working set should depend on how far your secondaries are behind the master.

Hope it helps!

Upvotes: 2

Related Questions