MongoDB Memory Usage Analysis _ server Other

Source: Internet
Author: User
Tags mongodb

MongoDB is a database based on distributed file storage. Written by the C + + language. Designed to provide scalable, high-performance data storage solutions for Web applications.

MongoDB is a product between relational database and non relational database, and is the most powerful and relational database in the relational database. The data structure he supports is very loose and is a JSON-like Bson format, so you can store more complex data types. The biggest feature of MONGO is that the query language he supports is very powerful, and its syntax is somewhat similar to an object-oriented query language, which can almost achieve most of the functions of a single table query like relational database, and also supports indexing of data.

PS First Look.

Copy Code code as follows:

$ ps Aux|grep Mongod
MONGO 26994 9.0 20.0 797264324 13243052? Sl MAY16 117:03/path/to/mongodb/bin/mongod

A total of more than 760G of virtual memory, but the physical memory is only 12.6G. This machine has 64G of memory, which looks like MongoDB completely useless memory.

And look at the results of free.

Copy Code code as follows:

$ free-m
Total used free shared buffers Cached
mem:64544 64279 265 0 134 60413
-/+ buffers/cache:3731 60813
swap:31999 0 31999

Memory is about the same, basically are cached, that is, file system caching. MongoDB is the mmap way for the operating system to handle persistence and caching. Each data file is mapped directly to a virtual memory address. If this page is not in memory during the visit, the system will try to load the page in. These memory are counted into the cache. In the official document of MongoDB, it is said that the rsize segment in top or PS shows the total memory size of the machine, as the MongoDB consumes as much memory as possible. But in fact, these caches are not counted. Therefore, in the top or PS can not see the actual memory usage of MongoDB. While free can see the memory usage of the system, it is impossible to determine how much of this memory is really MongoDB used.

Fortunately someone has done vmtouch this tool. You can check the file's status in the cache, or you can load the file directly into the cache or kick it out. Just check the cache load on all MongoDB data files to see how much data the MongoDB is caching.

Copy Code code as follows:

$ vmtouch-m4g/path/to/mongodb/data/
files:256
Directories:3
Resident pages:15465901/100219772 58g/382g 15.4%
elapsed:4.072 seconds

Here-m4g is the Vmtouch check file size limit. MongoDB data files are larger and typically exceed the default 500M. So it looks like the cache is 58G, and that's pretty much it. The number on the left of resident pages is the number of pages, and the number of pages multiplied by the file system page size is memory usage. The size of the page can be passed

Copy Code code as follows:

Getconf PAGESIZE

View, usually 4096, which is 4KB.

When MongoDB is running on a NUMA machine and memory is pinned to a node, there is a warning

Copy Code code as follows:

Warning:you are running on a NUMA machine.
We suggest launching Mongod to avoid performance problems:
Numactl–interleave=all Mongod [Other options]

Perhaps it is thought that in this case only the memory of the last node can be used. However, the MongoDB cache is managed by the operating system. NUMA does not seem to have any effect on this. And when memory is not too small, MongoDB itself is difficult to use the memory of a node. In this case, whether to open numactl–interleave=all effect is not much. Can do may only add memory, sharding, or change SSD.

Source: http://xiezhenye.com/2013/05/mongodb-%e5%86%85%e5%ad%98%e4%bd%bf%e7%94%a8.html

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.