MongoDB How to store data

Source: Internet
Author: User
Tags mongodb

To get an insight into how MongoDB stores data, one concept must be clear, and that is memeory-mapped Files.

memeory-mapped Files

The following figure shows how the database deals with the underlying system.

The memory-mapped file is the OS creates a data file in memory via Mmap, which maps the file to a region of virtual memory.

Virtual memory is an abstraction of physical memory for the process, with an address space of 2^64 size

The operating system maps all the data required by the process to this address space (red line) through Mmap, and then maps the data currently needed to be processed to physical memory (gray lines)

When a process accesses a data, if the data is not in virtual memory, triggers page fault, and then the OS loads the data into virtual and physical memory from the hard disk

If the physical memory is full, triggering the swap-out operation, some data will need to be written back to the disk, if it is pure memory data, write back to the swap partition, if not write back to the disk.

Storage model for MongoDB

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.