


What is the role of the MMAPv1 storage engine (legacy) and its key characteristics?
Jun 12, 2025 am 10:25 AMMMAPv1 is a storage engine used by MongoDB in the early days and has been replaced by WiredTiger, but it still works in some older deployments or specific scenarios. 1. It is based on the memory-mapped file mechanism, and relies on operating system cache rather than internal cache, which simplifies implementation but has weak control; 2. Adopt pre-allocation strategy to reduce fragmentation, but may lead to waste of space; 3. Use global write locks to limit concurrency performance, suitable for scenarios that read more and write less; 4. Support logs but are not as efficient as WiredTiger, which poses a certain risk of data loss; 5. Suitable for scenarios such as low memory, embedded systems or maintenance of old systems, but new deployments recommend using WiredTiger for better performance and functional support.
The MMAPv1 storage engine was MongoDB's original storage engine and is now considered legacy. It played a major role in MongoDB's early adoption due to its simplicity and compatibility with a wide range of environments. Though it's no longer the default (replaced by WiredTiger), understanding MMAPv1 can still be useful when dealing with older deployments or specific use cases that might benefit from its characteristics.
How MMAPv1 Works: Memory-Mapped Files
MMAPv1 relies on memory-mapped files to manage data. This means that the database files are directly mapped into the operating system's virtual memory space. As a result:
- Data reads and writes go through the filesystem cache managed by the OS.
- There's no internal caching mechanism within the storage engine itself — it depends entirely on the OS for caching.
- Performance can vary depending on how well the OS manages memory and which other processes are running.
This approach simplifies the implementation but gives less control over memory usage compared to newer engines like WiredTiger.
File Allocation and Preallocation Strategy
One notable behavior of MMAPv1 is how it handles disk space:
- It preallocates data files in advance to avoid fragmentation and performance issues during growth.
- Each new database starts with several preallocated files (typically around 3–5 files, each 64MB initially).
- Collections are stored in a single namespace file (
<dbname>.0</dbname>
,<dbname>.1</dbname>
, etc.), which can lead to wasted space if collections grow unevenly.
This can cause databases to take up more disk space than strictly needed, especially when starting out or after large deletions.
Concurrency and Locking Model
MMAPv1 uses a global write lock at the instance level, though it allows read operations to proceed concurrently with writes. This means:
- Only one write operation can happen at a time across the entire MongoDB instance.
- Read operations can block behind writes, leading to potential bottlenecks under heavy write loads.
- Performance may degrade significantly under high concurrency.
If your workload involves frequently writes or multiple collections being updated simultaneously, MMAPv1 may not be the best choice.
Journaling and Durability
MMAPv1 supports journaling to protect against crashes:
- Write operations are first written to the journal before being applied to the data files.
- The journal is flushed every 100–200 million seconds by default, meaning some data loss is possible in case of a crash.
- Journaling adds overhead but is essential for maintaining data integrity.
It's worth noting that journaling in MMAPv1 doesn't offer the same efficiency as in WiredTiger, partly due to the way data is structured and flushed.
Why Use MMAPv1 Today?
While MMAPv1 has been deprecated for most use cases, there are still a few scenarios where it might make sense:
- Running on systems with very limited RAM (since it offloads caching to the OS).
- Maintaining compatibility with old applications or backups that were built with MMAPv1.
- Embedded systems where simplicity and minimum dependencies matter more than advanced features.
That said, unless you have a clear reason, it's generally better to stick with WiredTiger for better performance, compression, and concurrency support.
So while MMAPv1 isn't recommended for new deployments, knowing how it works helps when maintaining legacy systems or troubleshooting older setups. It's straightforward, predictable in some ways, and closely tied to how the OS managements memory — which can be both a strength and a limitation.
The above is the detailed content of What is the role of the MMAPv1 storage engine (legacy) and its key characteristics?. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undress AI Tool
Undress images for free

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

MySQL is a powerful open source relational database that can be used in applications of all sizes. MySQL supports a variety of different storage engines, such as MyISAM, InnoDB, Memory, CSV, etc. Different engines have different functions and performance characteristics. When optimizing the underlying MySQL, the choice of storage engine is a very important step. This article will discuss how to choose a storage engine suitable for your project and how to compare performance. 1. MyISAM storage engine MyIS

Efficient storage and high-speed reading: MySQL tips and strategies for using the Aria engine Introduction: As a commonly used relational database management system, MySQL provides a variety of storage engines for users to choose from. Among them, the Aria engine is a storage engine that supports transactions and concurrent read and write operations, and has efficient storage and high-speed reading characteristics. This article will introduce several techniques and strategies for using the Aria engine to improve MySQL storage and reading performance, and provide corresponding code examples. Basic usage of Aria engine in MyS

Choosing the appropriate storage structure using the MySQL storage engine When using the MySQL database, choosing the appropriate storage engine is crucial. Different storage engines have different characteristics and applicable scenarios. Choosing a suitable storage engine can improve database performance and efficiency. This article will introduce several common storage engines in MySQL and give corresponding code examples. InnoDB engine The InnoDB engine is MySQL's default storage engine, which has transaction support and ACID features. It is suitable for handling high-concurrency applications

MySQL can change the storage engine of a table by specifying the storage engine when creating the table, using the ALTER TABLE statement to modify the storage engine, modifying the MySQL configuration file, and using the storage engine conversion tool. Detailed introduction: 1. Specify the storage engine when creating a table. When creating a table, you can change the default storage engine of the table by specifying the storage engine. By using the ENGINE keyword and specifying the storage engine name in the CREATE TABLE statement, you can change the table's default storage engine. The storage engine is set to InnoDB and so on.

How to write a custom storage engine in MySQL using C# Summary: MySQL is a popular relational database management system that provides many built-in storage engines, such as InnoDB, MyISAM, etc. However, sometimes we need to customize the storage engine to meet specific needs. This article will introduce how to write a custom storage engine using C# and provide detailed code examples. Introduction MySQL's storage engine is the core component responsible for processing data. It is responsible for data storage, retrieval, indexing and other operations. My

Tips and strategies to improve the read performance of MySQL storage engine: Comparative analysis of MyISAM and InnoDB Introduction: MySQL is one of the most commonly used open source relational database management systems, mainly used to store and manage large amounts of structured data. In applications, the read performance of the database is often very important, because read operations are the main type of operations in most applications. This article will focus on how to improve the read performance of the MySQL storage engine, focusing on a comparative analysis of MyISAM and InnoDB, two commonly used storage engines.

How to use Python to write custom triggers, storage engines, and functions in MySQL MySQL is a widely used relational database management system, and Python is a powerful scripting language. Combining the two, we can implement custom triggers, storage engines and functions by writing Python scripts. This article will introduce how to use Python to write custom triggers, storage engines and functions in MySQL, and provide specific code examples. 1. Custom trigger The trigger is

Steps for MySQL to modify the storage engine of a data table: 1. Check the storage engine used by the current data table; 2. Back up the data table to prevent data loss due to unexpected situations during the modification process; 3. You can use the ALTER TABLE statement to modify the data table. Storage engine; 4. Use the SHOW CREATE TABLE statement to verify the modification results; 5. If a problem occurs during the modification of the storage engine of the data table, the data table can be restored by restoring the backup data table.
